diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-06-19 10:49:37 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-06-19 10:49:37 -0700 |
commit | 16ea58b34b37947f40b3d9f90356a64099b250a7 (patch) | |
tree | d9029dfb0c619d74047850ac6d990afe74fe6486 /src | |
parent | e2b4db06f20894b6f14b929c1d2c7f15e1af68ee (diff) | |
parent | 8c0f444ba550dbd2aa7071cf840aec7b6ada03cb (diff) | |
download | scala-16ea58b34b37947f40b3d9f90356a64099b250a7.tar.gz scala-16ea58b34b37947f40b3d9f90356a64099b250a7.tar.bz2 scala-16ea58b34b37947f40b3d9f90356a64099b250a7.zip |
Merge pull request #2631 from retronym/ticket/5022
SI-5022 Retain precise existentials through pattern matching
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8d422f415d..27b03001ee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5111,7 +5111,7 @@ trait Typers extends Adaptations with Tags { if (mode.inPatternMode) { val uncheckedTypeExtractor = extractorForUncheckedType(tpt.pos, tptTyped.tpe) // make fully defined to avoid bounded wildcard types that may be in pt from calling dropExistential (SI-2038) - val ptDefined = ensureFullyDefined(pt) + val ptDefined = ensureFullyDefined(pt) // FIXME this is probably redundant now that we don't dropExistenial in pattern mode. val ownType = inferTypedPattern(tptTyped, tptTyped.tpe, ptDefined, canRemedy = uncheckedTypeExtractor.nonEmpty) treeTyped setType ownType @@ -5345,7 +5345,12 @@ trait Typers extends Adaptations with Tags { "context.owner" -> context.owner ) ) - typed1(tree, mode, dropExistential(ptPlugins)) + val ptWild = if (mode.inPatternMode) + ptPlugins // SI-5022 don't widen pt for patterns as types flow from it to the case body. + else + dropExistential(ptPlugins) // FIXME: document why this is done. + + typed1(tree, mode, ptWild) } // Can happen during erroneous compilation - error(s) have been // reported, but we need to avoid causing an NPE with this tree |