diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-01-25 22:11:19 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-01-25 22:40:28 +1000 |
commit | b2093f2345b991fa4774950c5505621ab6445897 (patch) | |
tree | aaa0e87e8aad907d64985cb3aa51cd011ed92b53 /src/compiler | |
parent | 1081e718f8f8e174dbf615e42b157e187d3d3886 (diff) | |
download | scala-b2093f2345b991fa4774950c5505621ab6445897.tar.gz scala-b2093f2345b991fa4774950c5505621ab6445897.tar.bz2 scala-b2093f2345b991fa4774950c5505621ab6445897.zip |
SI-9629 Emit missing 'pattern must be a value' error
The error used to only be emitted for top-level patterns.
This commit moves it into `typedInternal` so it works
for nested patterns. It uses the typer mode to know
when to fire.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 84af9233e1..2c0c8b8066 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5421,6 +5421,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (!isPastTyper) signalDone(context.asInstanceOf[analyzer.Context], tree, result) + if (mode.inPatternMode && !mode.inPolyMode && result.isType) + PatternMustBeValue(result, pt) + result } @@ -5510,10 +5513,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // as a compromise, context.enrichmentEnabled tells adaptToMember to go ahead and enrich, // but arbitrary conversions (in adapt) are disabled // TODO: can we achieve the pattern matching bit of the string interpolation SIP without this? - typingInPattern(context.withImplicitsDisabledAllowEnrichment(typed(tree, PATTERNmode, pt))) match { - case tpt if tpt.isType => PatternMustBeValue(tpt, pt); tpt - case pat => pat - } + typingInPattern(context.withImplicitsDisabledAllowEnrichment(typed(tree, PATTERNmode, pt))) } /** Types a (fully parameterized) type tree */ |