File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -3649,7 +3649,7 @@ object Parsers {
36493649 in.observeIndented()
36503650 newLineOptWhenFollowedBy(LBRACE )
36513651 if in.isNestedStart then inDefScopeBraces(extMethods(nparams))
3652- else { syntaxError (" Extension without extension methods" ); Nil }
3652+ else { syntaxErrorOrIncomplete (" Extension without extension methods" ) ; Nil }
36533653 val result = atSpan(start)(ExtMethods (joinParams(tparams, leadParamss.toList), methods))
36543654 val comment = in.getDocComment(start)
36553655 if comment.isDefined then
@@ -3671,10 +3671,15 @@ object Parsers {
36713671 def extMethods (numLeadParams : Int ): List [DefDef ] = checkNoEscapingPlaceholders {
36723672 val meths = new ListBuffer [DefDef ]
36733673 while
3674- meths += extMethod(numLeadParams)
3675- statSepOrEnd(meths, what = " extension method" )
3674+ val start = in.offset
3675+ val mods = defAnnotsMods(modifierTokens)
3676+ in.token != EOF && {
3677+ accept(DEF )
3678+ meths += defDefOrDcl(start, mods, numLeadParams)
3679+ in.token != EOF && statSepOrEnd(meths, what = " extension method" )
3680+ }
36763681 do ()
3677- if meths.isEmpty then syntaxError (" `def` expected" )
3682+ if meths.isEmpty then syntaxErrorOrIncomplete (" `def` expected" )
36783683 meths.toList
36793684 }
36803685
Original file line number Diff line number Diff line change @@ -199,6 +199,12 @@ class ReplCompilerTests extends ReplTest {
199199 assertFalse(ParseResult .isIncomplete(" _ + 1" )) // was: assertThrows[NullPointerException]
200200 }
201201
202+ @ Test def `i9374 accept collective extensions` : Unit = fromInitialState { state =>
203+ given Context = state.context
204+ assert(ParseResult .isIncomplete(" extension (x: String)" ))
205+ assert(ParseResult .isIncomplete(" extension (x: String) {" ))
206+ }
207+
202208 @ Test def testSingletonPrint = fromInitialState { implicit state =>
203209 run(""" val a = "hello"; val x: a.type = a""" )
204210 assertMultiLineEquals(" val a: String = hello\n val x: a.type = hello" , storedOutput().trim)
You can’t perform that action at this time.
0 commit comments