diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-08-16 11:30:33 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-08-16 12:12:52 +0200 |
commit | 42e0f73311cfaf0883b85a1a41f400c3eb3cae96 (patch) | |
tree | f2604b498f99319f6ffc5ac52972af0ee22826ba /src | |
parent | 8053c197941608b06089de4a618615d46552aa0b (diff) | |
download | scala-42e0f73311cfaf0883b85a1a41f400c3eb3cae96.tar.gz scala-42e0f73311cfaf0883b85a1a41f400c3eb3cae96.tar.bz2 scala-42e0f73311cfaf0883b85a1a41f400c3eb3cae96.zip |
SI-7716 Exclude patmat synthetics from bounds checking
Consider this pattern match translation, that occurs *before* refchecks:
scala> val e: java.lang.Enum[_] = java.util.concurrent.TimeUnit.SECONDS
scala> e match { case x => x }
<console>:9: error: type arguments [_$1] do not conform to class Enum's type parameter bounds [E <: Enum[E]]
e match { case x => x }
^
[[syntax trees at end of refchecks]] // <console>
package $line5 {
case <synthetic> val x1: Enum[_$1] = $line3.$read.$iw.$iw.e;
case4(){
matchEnd3(x1)
};
matchEnd3(x: Enum[_$1]){
x
}
RefChecks turns a blind eye to the non-conformant type `Enum[_$1]` in
the label defs because of `65340ed4ad2e`. (Incidentally, that is far
too broad, as I've noted in SI-7756.)
This commit extends this exception to cover the synthetic ValDef `x1`.
Commit log watchers might notice the similarities to SI-7694.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index db899b44f9..09c4878b2f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1826,9 +1826,11 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case LabelDef(_, _, _) if treeInfo.hasSynthCaseSymbol(result) => val old = inPattern inPattern = true - val res = deriveLabelDef(result)(transform) + val res = deriveLabelDef(result)(transform) // TODO SI-7756 Too broad! The code from the original case body should be fully refchecked! inPattern = old res + case ValDef(_, _, _, _) if treeInfo.hasSynthCaseSymbol(result) => + deriveValDef(result)(transform) // SI-7716 Don't refcheck the tpt of the synthetic val that holds the selector. case _ => super.transform(result) } |