summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Variances.scala
diff options
context:
space:
mode:
authorTiark Rompf <tiark.rompf@epfl.ch>2008-11-10 20:31:12 +0000
committerTiark Rompf <tiark.rompf@epfl.ch>2008-11-10 20:31:12 +0000
commit8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d (patch)
treec2cf883e6759ee6749ec0160b5ac7ab83cb5177e /src/compiler/scala/tools/nsc/typechecker/Variances.scala
parent5d6c2cb4c663f4351f5eacb6c9f6f9b0cedf4966 (diff)
downloadscala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.tar.gz
scala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.tar.bz2
scala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.zip
fixed #1500 and #1501
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Variances.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Variances.scala14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala
index b5efa7035d..e0cbc99fa0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala
@@ -64,6 +64,18 @@ trait Variances {
v
}
+ /** Compute variance of type parameter `tparam' in all type annotations `attribs'. */
+ def varianceInAttribs(attribs: List[AnnotationInfo])(tparam: Symbol): Int = {
+ (VARIANCES /: attribs) ((v, attrib) => v & varianceInAttrib(attrib)(tparam))
+ }
+
+ /** Compute variance of type parameter `tparam' in type annotation `attrib'. */
+ def varianceInAttrib(attrib: AnnotationInfo)(tparam: Symbol): Int = {
+ varianceInType(attrib.atp)(tparam)
+ }
+
+
+
/** Compute variance of type parameter <code>tparam</code> in type <code>tp</code>. */
def varianceInType(tp: Type)(tparam: Symbol): Int = tp match {
case ErrorType | WildcardType | NoType | NoPrefix | ThisType(_) | ConstantType(_) =>
@@ -84,6 +96,6 @@ trait Variances {
case ExistentialType(tparams, restpe) =>
varianceInSyms(tparams)(tparam) & varianceInType(restpe)(tparam)
case AnnotatedType(attribs, tp, _) =>
- varianceInType(tp)(tparam)
+ varianceInAttribs(attribs)(tparam) & varianceInType(tp)(tparam)
}
}