Parsing: allow primary ctor in object syntactically
It's needed for better recovering for cases of changes like 'class' -> 'object'
The only sensible case when it's may be bad:
class A {
object B
constructor() : super()
}
But it seems to be rare, and ';' can be used to separate object from secondary ctor
This commit is contained in:
@@ -17,12 +17,15 @@ internal class Example<X, T : Comparable<X>>(protected val x : Foo<X, T>, y : So
|
||||
class
|
||||
: modifiers ("class" | "trait") SimpleName
|
||||
typeParameters?
|
||||
(modifiers "constructor")? ("(" functionParameter{","} ")")?
|
||||
primaryConstructor?
|
||||
(":" annotations delegationSpecifier{","})?
|
||||
typeConstraints
|
||||
(classBody? | enumClassBody)
|
||||
;
|
||||
|
||||
primaryConstructor
|
||||
: (modifiers "constructor")? ("(" functionParameter{","} ")")
|
||||
;
|
||||
|
||||
classBody
|
||||
: ("{" members "}")?
|
||||
|
||||
@@ -111,7 +111,7 @@ parameter
|
||||
;
|
||||
|
||||
object
|
||||
: "object" SimpleName (":" delegationSpecifier{","})? classBody? // Class body can be optional: this is a declaration
|
||||
: "object" SimpleName primaryConstructor? (":" delegationSpecifier{","})? classBody? // Class body can be optional: this is a declaration
|
||||
|
||||
secondaryConstructor
|
||||
: modifiers "constructor" valueParameters (":" constructorDelegationCall)? block
|
||||
|
||||
Reference in New Issue
Block a user