diff options
author | Tiark Rompf <tiark.rompf@epfl.ch> | 2008-11-10 20:31:12 +0000 |
---|---|---|
committer | Tiark Rompf <tiark.rompf@epfl.ch> | 2008-11-10 20:31:12 +0000 |
commit | 8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d (patch) | |
tree | c2cf883e6759ee6749ec0160b5ac7ab83cb5177e /src/compiler | |
parent | 5d6c2cb4c663f4351f5eacb6c9f6f9b0cedf4966 (diff) | |
download | scala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.tar.gz scala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.tar.bz2 scala-8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d.zip |
fixed #1500 and #1501
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Variances.scala | 14 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 0cb94b899f..81a4258b06 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1903,6 +1903,15 @@ A type's typeSymbol should never be inspected directly. } } + // ** Replace formal type parameter symbols with actual type arguments. * / + override def instantiateTypeParams(formals: List[Symbol], actuals: List[Type]) = { + val attributes1 = attributes.map(info => AnnotationInfo(info.atp.instantiateTypeParams( + formals, actuals), info.args, info.assocs)) + val underlying1 = underlying.instantiateTypeParams(formals, actuals) + if ((attributes1 eq attributes) && (underlying1 eq underlying)) this + else AnnotatedType(attributes1, underlying1, selfsym) + } + /** Return the base type sequence of tp, dropping the annotations, unless the base type sequence of tp * is precisely tp itself. */ override def baseTypeSeq: BaseTypeSeq = { 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) } } |