diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-01-26 17:12:01 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-01-26 17:20:27 +0100 |
commit | b8da00ef01d06ff8588813c7f392679f19b0d374 (patch) | |
tree | cdd8d95b3c710a99b371b2cd1e936fc3070090a7 /src/compiler | |
parent | 2fa859e1b3eb2ac57058feaba87d96adfbac9209 (diff) | |
download | scala-b8da00ef01d06ff8588813c7f392679f19b0d374.tar.gz scala-b8da00ef01d06ff8588813c7f392679f19b0d374.tar.bz2 scala-b8da00ef01d06ff8588813c7f392679f19b0d374.zip |
[backport] SI-3577 BoundedWildcardType handling
commit 3c91b32d699a9e29d685ac20c9805f96c9f2db2c
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 01:16:47 2012 +0200
Mention BoundedWildcardType in "a standard type pattern match".
(cherry picked from commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9)
commit 0664be2b69b1ce013e937bc93f4e84b891676f1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 01:05:07 2012 +0200
Make RefChecks#validateVariance aware of BoundedWildcardType.
The only test case that I know for this will be neutered
by the imminent fix for SI-6258; so I haven't been able to
test this.
But trying this manually, you can see that this patch defers the
the SI-6258 to the erasure phase.
Original:
scala.MatchError: ? (of class scala.reflect.internal.Types$BoundedWildcardType)
at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.scala$tools$nsc$typechecker$RefChecks$RefCheckTransformer$$anon$$validateVariance$1(RefChecks.scala:894)
at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.validateVariance(RefChecks.scala:965)
Modified:
java.lang.ClassCastException: scala.reflect.internal.Types$TypeRef$$anon$6 cannot be cast to scala.reflect.internal.Types$TypeBounds
at scala.reflect.internal.Types$TypeMap.mapOver(Types.scala:4160)
at scala.reflect.internal.transform.Erasure$ErasureMap.apply(Erasure.scala:156)
(cherry picked from commit 2b4e7183fd24113cca5e868456668fd05c848168)
commit 6ad651c94faf463133c742feb2aee59ef782ea1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 00:54:59 2012 +0200
SI-3577 Make varianceInType aware of BoundedWildcardType.
(cherry picked from commit 21105654c40ed0c462142bcbb6c8eced77f8b07a)
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 16 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Variances.scala | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 969bb8aceb..96e480cc84 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -905,13 +905,15 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans * the type occurs itself at variance position given by `variance` */ def validateVariance(tp: Type, variance: Int): Unit = tp match { - case ErrorType => ; - case WildcardType => ; - case NoType => ; - case NoPrefix => ; - case ThisType(_) => ; - case ConstantType(_) => ; - // case DeBruijnIndex(_, _) => ; + case ErrorType => + case WildcardType => + case BoundedWildcardType(bounds) => + validateVariance(bounds, variance) + case NoType => + case NoPrefix => + case ThisType(_) => + case ConstantType(_) => + // case DeBruijnIndex(_, _) => case SingleType(pre, sym) => validateVariance(pre, variance) case TypeRef(pre, sym, args) => diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index 7d97b0c782..ea436a71fb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -67,6 +67,8 @@ trait Variances { def varianceInType(tp: Type)(tparam: Symbol): Int = tp match { case ErrorType | WildcardType | NoType | NoPrefix | ThisType(_) | ConstantType(_) => VARIANCES + case BoundedWildcardType(bounds) => + varianceInType(bounds)(tparam) case SingleType(pre, sym) => varianceInType(pre)(tparam) case TypeRef(pre, sym, args) => |