diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-10-08 21:20:23 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-10-09 09:32:45 +0200 |
commit | d0af55ce1ffb9d77e6a604edb41cda2b955e9f02 (patch) | |
tree | 66b9b41e4525287ef892d68ba140a804db475e25 /src/compiler | |
parent | acd77803f7da7c369f4ffdc70b5eeec4a23e35ae (diff) | |
download | scala-d0af55ce1ffb9d77e6a604edb41cda2b955e9f02.tar.gz scala-d0af55ce1ffb9d77e6a604edb41cda2b955e9f02.tar.bz2 scala-d0af55ce1ffb9d77e6a604edb41cda2b955e9f02.zip |
SI-7895 Avoid cascade of "symbol not found" in pattern matches
If we can't type check the `Foo` in `case Foo(a, b) => (a, b)`,
we should enter error symbols for `a` and `b` to avoid further
errors being reported in the case body.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ecd987b031..e7371fa26b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2392,9 +2392,16 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (pat1.tpe.paramSectionCount > 0) pat1 modifyType (_.finalResultType) - for (bind @ Bind(name, _) <- cdef.pat) - if (name.toTermName != nme.WILDCARD && bind.symbol != null && bind.symbol != NoSymbol) - namer.enterIfNotThere(bind.symbol) + for (bind @ Bind(name, _) <- cdef.pat) { + val sym = bind.symbol + if (name.toTermName != nme.WILDCARD && sym != null) { + if (sym == NoSymbol) { + if (context.scope.lookup(name) == NoSymbol) + namer.enterInScope(context.owner.newErrorSymbol(name)) + } else + namer.enterIfNotThere(sym) + } + } val guard1: Tree = if (cdef.guard == EmptyTree) EmptyTree else typed(cdef.guard, BooleanTpe) |