Skip to content

Commit ca0f228

Browse files
committed
Fix #1703 - survive illegal self type clause
Since self types are critical we should only install one if it is syntactcally correct. Fixes #1703.
1 parent fb59174 commit ca0f228

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,8 @@ object Parsers {
21492149
self = makeSelfDef(nme.WILDCARD, tpt).withPos(first.pos)
21502150
case _ =>
21512151
val ValDef(name, tpt, _) = convertToParam(first, expected = "self type clause")
2152-
self = makeSelfDef(name, tpt).withPos(first.pos)
2152+
if (name != nme.ERROR)
2153+
self = makeSelfDef(name, tpt).withPos(first.pos)
21532154
}
21542155
in.nextToken()
21552156
} else {

tests/pos/i1703.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class DuplicateClassName { () => {
2+
{ () =>
3+
}
4+
}
5+
}

0 commit comments

Comments
 (0)