From 8a69a88c9a72aaf9971fb4feb92b1c25c106ff3d Mon Sep 17 00:00:00 2001 From: Tiark Rompf Date: Mon, 10 Nov 2008 20:31:12 +0000 Subject: fixed #1500 and #1501 --- src/compiler/scala/tools/nsc/symtab/Types.scala | 9 +++++++++ src/compiler/scala/tools/nsc/typechecker/Variances.scala | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/compiler') 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 tparam in type tp. */ 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) } } -- cgit v1.2.3