diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-09 14:44:47 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-09 14:58:25 -0800 |
commit | 8fb19b132579b7ddb9dd12ae829451dcf9d91332 (patch) | |
tree | 2cb58cb3d90497d2086f66c0a195dfb1a04efce6 /src | |
parent | 1381cda86ddeca1b9829a9c53ff9372cfd816735 (diff) | |
download | scala-8fb19b132579b7ddb9dd12ae829451dcf9d91332.tar.gz scala-8fb19b132579b7ddb9dd12ae829451dcf9d91332.tar.bz2 scala-8fb19b132579b7ddb9dd12ae829451dcf9d91332.zip |
SI-5189 detect unsoundness when inferring type of match
GADT skolems encode type slack that results from pattern matching on variant type constructors
I thought they would not longer be relevant after cases have been typed,
and since they caused weird issues with the old pattern matcher, I deskolemized in typedCase
however, when we don't have an expected type for the match, we need to keep the skolems around
until the skolemized type makes it out of the match and it becomes the result of type inference for that match
when you do have an expected type, it will propagate to the case-level and the confrontation will thus
already take place when typing individual cases
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9d390476db..5fe223dde6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2523,11 +2523,7 @@ trait Typers extends Modes with Adaptations with Tags { } // body1 = checkNoEscaping.locals(context.scope, pt, body1) - val treeWithSkolems = treeCopy.CaseDef(cdef, pat1, guard1, body1) setType body1.tpe - - new TypeMapTreeSubstituter(deskolemizeGADTSkolems).traverse(treeWithSkolems) - - treeWithSkolems // now without skolems, actually + treeCopy.CaseDef(cdef, pat1, guard1, body1) setType body1.tpe } // undo adaptConstrPattern's evil deeds, as they confuse the old pattern matcher @@ -2562,7 +2558,10 @@ trait Typers extends Modes with Adaptations with Tags { val casesAdapted = if (!needAdapt) casesTyped else casesTyped map (adaptCase(_, mode, resTp)) - treeCopy.Match(tree, selector1, casesAdapted) setType resTp + val matchTyped = treeCopy.Match(tree, selector1, casesAdapted) setType resTp + if (!newPatternMatching) // TODO: remove this in 2.11 -- only needed for old pattern matcher + new TypeMapTreeSubstituter(deskolemizeGADTSkolems).traverse(matchTyped) + matchTyped } // match has been typed -- virtualize it if we're feeling experimental |