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 @@ -3652,7 +3652,7 @@ object Parsers {
3652
3652
in.observeIndented()
3653
3653
newLineOptWhenFollowedBy(LBRACE )
3654
3654
if in.isNestedStart then inDefScopeBraces(extMethods(nparams))
3655
- else { syntaxError (" Extension without extension methods" ); Nil }
3655
+ else { syntaxErrorOrIncomplete (" Extension without extension methods" ) ; Nil }
3656
3656
val result = atSpan(start)(ExtMethods (joinParams(tparams, leadParamss.toList), methods))
3657
3657
val comment = in.getDocComment(start)
3658
3658
if comment.isDefined then
@@ -3674,10 +3674,15 @@ object Parsers {
3674
3674
def extMethods (numLeadParams : Int ): List [DefDef ] = checkNoEscapingPlaceholders {
3675
3675
val meths = new ListBuffer [DefDef ]
3676
3676
while
3677
- meths += extMethod(numLeadParams)
3678
- statSepOrEnd(meths, what = " extension method" )
3677
+ val start = in.offset
3678
+ val mods = defAnnotsMods(modifierTokens)
3679
+ in.token != EOF && {
3680
+ accept(DEF )
3681
+ meths += defDefOrDcl(start, mods, numLeadParams)
3682
+ in.token != EOF && statSepOrEnd(meths, what = " extension method" )
3683
+ }
3679
3684
do ()
3680
- if meths.isEmpty then syntaxError (" `def` expected" )
3685
+ if meths.isEmpty then syntaxErrorOrIncomplete (" `def` expected" )
3681
3686
meths.toList
3682
3687
}
3683
3688
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