Skip to content

Commit 3bec283

Browse files
committed
Fix #4453: Avoid adding type bindings in getVariables
getVariables is used when desugaring `val/var/lazy val pat = e` but after other errors `pat` may contain a type name.
1 parent 03887b7 commit 3bec283

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ object desugar {
14401440
val buf = new ListBuffer[VarInfo]
14411441
def seenName(name: Name) = buf exists (_._1.name == name)
14421442
def add(named: NameTree, t: Tree): Unit =
1443-
if (!seenName(named.name)) buf += ((named, t))
1443+
if (!seenName(named.name) && named.name.isTermName) buf += ((named, t))
14441444
def collect(tree: Tree): Unit = tree match {
14451445
case Bind(nme.WILDCARD, tree1) =>
14461446
collect(tree1)

tests/neg/i4453.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class x0 { var x0 == _ * // error: _* can be used only for last argument // error: == cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method
2+
// error '=' expected, but eof found

0 commit comments

Comments
 (0)