@@ -1364,6 +1364,7 @@ object Parsers {
13641364 val start = in.offset
13651365 var imods = Modifiers ()
13661366 def functionRest (params : List [Tree ]): Tree =
1367+ val paramSpan = Span (start, in.lastOffset)
13671368 atSpan(start, in.offset) {
13681369 if in.token == TLARROW then
13691370 if ! imods.flags.isEmpty || params.isEmpty then
@@ -1382,14 +1383,16 @@ object Parsers {
13821383 accept(ARROW )
13831384 val t = typ()
13841385
1385- if (imods.isOneOf(Given | Erased )) new FunctionWithMods (params, t, imods)
1386- else if (ctx.settings.YkindProjector .value) {
1386+ if imods.isOneOf(Given | Erased ) then
1387+ if imods.is(Given ) && params.isEmpty then
1388+ syntaxError(" context function types require at least one parameter" , paramSpan)
1389+ new FunctionWithMods (params, t, imods)
1390+ else if ctx.settings.YkindProjector .value then
13871391 val (newParams :+ newT, tparams) = replaceKindProjectorPlaceholders(params :+ t)
13881392
13891393 lambdaAbstract(tparams, Function (newParams, newT))
1390- } else {
1394+ else
13911395 Function (params, t)
1392- }
13931396 }
13941397 def funArgTypesRest (first : Tree , following : () => Tree ) = {
13951398 val buf = new ListBuffer [Tree ] += first
@@ -1904,10 +1907,7 @@ object Parsers {
19041907
19051908 def expr (location : Location ): Tree = {
19061909 val start = in.offset
1907- def isSpecialClosureStart =
1908- val lookahead = in.LookaheadScanner ()
1909- lookahead.nextToken()
1910- lookahead.isIdent(nme.using) || lookahead.token == ERASED
1910+ def isSpecialClosureStart = in.lookahead.token == ERASED
19111911 if in.token == IMPLICIT then
19121912 closure(start, location, modifiers(BitSet (IMPLICIT )))
19131913 else if in.token == LPAREN && isSpecialClosureStart then
@@ -2137,9 +2137,7 @@ object Parsers {
21372137 else
21382138 openParens.change(LPAREN , 1 )
21392139 var mods1 = mods
2140- if mods.flags.isEmpty then
2141- if isIdent(nme.using) then mods1 = addMod(mods1, atSpan(in.skipToken()) { Mod .Given () })
2142- if in.token == ERASED then mods1 = addModifier(mods1)
2140+ if in.token == ERASED then mods1 = addModifier(mods1)
21432141 try
21442142 commaSeparated(() => binding(mods1))
21452143 finally
@@ -2188,7 +2186,12 @@ object Parsers {
21882186
21892187 def closureRest (start : Int , location : Location , params : List [Tree ]): Tree =
21902188 atSpan(start, in.offset) {
2191- if in.token == CTXARROW then in.nextToken() else accept(ARROW )
2189+ if in.token == CTXARROW then
2190+ if params.isEmpty then
2191+ syntaxError(" context function literals require at least one formal parameter" , Span (start, in.lastOffset))
2192+ in.nextToken()
2193+ else
2194+ accept(ARROW )
21922195 Function (params, if (location == Location .InBlock ) block() else expr())
21932196 }
21942197
0 commit comments