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 {
3649
3649
in.observeIndented()
3650
3650
newLineOptWhenFollowedBy(LBRACE )
3651
3651
if in.isNestedStart then inDefScopeBraces(extMethods(nparams))
3652
- else { syntaxError (" Extension without extension methods" ); Nil }
3652
+ else { syntaxErrorOrIncomplete (" Extension without extension methods" ) ; Nil }
3653
3653
val result = atSpan(start)(ExtMethods (joinParams(tparams, leadParamss.toList), methods))
3654
3654
val comment = in.getDocComment(start)
3655
3655
if comment.isDefined then
@@ -3671,10 +3671,15 @@ object Parsers {
3671
3671
def extMethods (numLeadParams : Int ): List [DefDef ] = checkNoEscapingPlaceholders {
3672
3672
val meths = new ListBuffer [DefDef ]
3673
3673
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
+ }
3676
3681
do ()
3677
- if meths.isEmpty then syntaxError (" `def` expected" )
3682
+ if meths.isEmpty then syntaxErrorOrIncomplete (" `def` expected" )
3678
3683
meths.toList
3679
3684
}
3680
3685
Original file line number Diff line number Diff line change @@ -199,6 +199,12 @@ class ReplCompilerTests extends ReplTest {
199
199
assertFalse(ParseResult .isIncomplete(" _ + 1" )) // was: assertThrows[NullPointerException]
200
200
}
201
201
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
+
202
208
@ Test def testSingletonPrint = fromInitialState { implicit state =>
203
209
run(""" val a = "hello"; val x: a.type = a""" )
204
210
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