@@ -913,7 +913,10 @@ object Parsers {
913913 lookahead.nextToken()
914914 if lookahead.token == IDENTIFIER then
915915 lookahead.nextToken()
916- lookahead.token == COLON
916+ if lookahead.token == COLON then
917+ lookahead.nextToken()
918+ ! lookahead.isAfterLineEnd
919+ else false
917920 else false
918921 else false
919922
@@ -943,7 +946,10 @@ object Parsers {
943946 lookahead.nextToken()
944947 while lookahead.token == LPAREN || lookahead.token == LBRACKET do
945948 lookahead.skipParens()
946- lookahead.token == COLON || lookahead.token == SUBTYPE
949+ if lookahead.token == COLON then
950+ lookahead.nextToken()
951+ ! lookahead.isAfterLineEnd
952+ else lookahead.token == SUBTYPE
947953
948954 def followingIsExtension () =
949955 val lookahead = in.LookaheadScanner ()
@@ -1304,7 +1310,12 @@ object Parsers {
13041310 }
13051311
13061312 def possibleTemplateStart (isNew : Boolean = false ): Unit =
1307- if in.token == WITH then
1313+ in.observeColonEOL()
1314+ if in.token == COLONEOL then
1315+ in.nextToken()
1316+ if in.token != INDENT then
1317+ syntaxError(i " indented definitions expected " )
1318+ else if in.token == WITH then
13081319 in.nextToken()
13091320 if in.token != LBRACE && in.token != INDENT then
13101321 syntaxError(i " indented definitions or `{` expected " )
@@ -3415,7 +3426,7 @@ object Parsers {
34153426 }
34163427
34173428 /** GivenDef ::= [GivenSig (‘:’ | <:)] {FunArgTypes ‘=>’} AnnotType ‘=’ Expr
3418- * | [GivenSig ‘:’] {FunArgTypes ‘=>’} ConstrApps [[ ‘with’] TemplateBody]
3429+ * | [GivenSig ‘:’] {FunArgTypes ‘=>’} ConstrApps [‘:’ nl | ‘with’] TemplateBody]
34193430 * | [id ‘:’] ExtParamClause {GivenParamClause} ‘extended’ ‘with’ ExtMethods
34203431 * GivenSig ::= [id] [DefTypeParamClause] {GivenParamClause}
34213432 * ExtParamClause ::= [DefTypeParamClause] DefParamClause
0 commit comments