ceylon / ceylon.ast

Apache License 2.0
18 stars 3 forks source link

constructors #71

Closed lucaswerkmeister closed 9 years ago

lucaswerkmeister commented 9 years ago

We need to support constructors. See ceylon/ceylon-spec#796.

EDIT: Let’s make a task list.

lucaswerkmeister commented 9 years ago

Also includes ceylon/ceylon-spec#1126.

lucaswerkmeister commented 9 years ago

So what’s the supertype of ConstructorDefinition? Per spec, a ConstructorDefinition can only appear within a ClassBody, not within an InterfaceBody or Block. However, without complement types ({Statement|Declaration~ConstructorDefinition*} content), this would be a bit ugly to enforce within the type system… unless we say that ConstructorDefinition doesn’t extend Declaration.

But that’s probably too weird. Perhaps that’s a restriction we can either do via assertions, or just omit from ceylon.ast altogether.

lucaswerkmeister commented 9 years ago

Regarding ExtendedType: I think we’ll get rid of ClassInstantiation and inline it into ClassSpecifier (unchanged) and ExtendedType (with the added possibility of a TypeNameWithTypeArguments qualifier).

lucaswerkmeister commented 9 years ago

Actually… the compiler completely accepts:

class C {
    shared new C() {}
    shared new D() {}
}
class D() => C.D();

even though, per the spec, a ClassSpecifier can only be qualified by super:

ClassSpecifier: "=>" ("super" ".")? TypeNameWithArguments PositionalArguments

So perhaps that rule just wasn’t updated, and in fact ClassSpecifier and ExtendedType still have the same syntax, meaning we can keep ClassInstantiation?

@gavinking?

gavinking commented 9 years ago

@lucaswerkmeister fixed.

lucaswerkmeister commented 9 years ago

Thanks, then I’ll keep ClassInstantiation.

lucaswerkmeister commented 9 years ago

Alright, I think we’re done here! I hope I haven’t forgotten anything…