diff options
author | Tiark Rompf <tiark.rompf@epfl.ch> | 2010-02-11 16:58:12 +0000 |
---|---|---|
committer | Tiark Rompf <tiark.rompf@epfl.ch> | 2010-02-11 16:58:12 +0000 |
commit | 1e166a7a826bb086d9bcb77ae973fa343277f84f (patch) | |
tree | 38cb269c0e1561f24a914515d2a175e41fdae78e | |
parent | e9a60f236b00d417ddd6fd2ac30448f0228b2921 (diff) | |
download | scala-1e166a7a826bb086d9bcb77ae973fa343277f84f.tar.gz scala-1e166a7a826bb086d9bcb77ae973fa343277f84f.tar.bz2 scala-1e166a7a826bb086d9bcb77ae973fa343277f84f.zip |
added annotation checker hook for Types.isWithi...
added annotation checker hook for Types.isWithinBounds. needed to allow
functions of type T => A @cps[B,C] even though A @cps[B,C] is not a
subtype of Any. review by odersky.
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/AnnotationCheckers.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/AnnotationCheckers.scala b/src/compiler/scala/tools/nsc/symtab/AnnotationCheckers.scala index f28fbeca96..945d9aa2fe 100644 --- a/src/compiler/scala/tools/nsc/symtab/AnnotationCheckers.scala +++ b/src/compiler/scala/tools/nsc/symtab/AnnotationCheckers.scala @@ -29,6 +29,10 @@ trait AnnotationCheckers { * All this should do is add annotations. */ def annotationsGlb(tp: Type, ts: List[Type]): Type = tp + /** Refine the bounds on type parameters to the given type arguments. */ + def adaptBoundsToAnnotations(bounds: List[TypeBounds], + tparams: List[Symbol], targs: List[Type]): List[TypeBounds] = bounds + /** Modify the type that has thus far been inferred * for a tree. All this should do is add annotations. */ def addAnnotations(tree: Tree, tpe: Type): Type = tpe @@ -86,6 +90,12 @@ trait AnnotationCheckers { checker.annotationsGlb(tpe, ts)) } + /** Refine the bounds on type parameters to the given type arguments. */ + def adaptBoundsToAnnotations(bounds: List[TypeBounds], + tparams: List[Symbol], targs: List[Type]): List[TypeBounds] = { + annotationCheckers.foldLeft(bounds)((bounds, checker) => + checker.adaptBoundsToAnnotations(bounds, tparams, targs)) + } /** Let all annotations checkers add extra annotations * to this tree's type. */ diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index dc324511fa..ab8c34d44d 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -4589,7 +4589,9 @@ A type's typeSymbol should never be inspected directly. * @return ... */ def isWithinBounds(pre: Type, owner: Symbol, tparams: List[Symbol], targs: List[Type]): Boolean = { - val bounds = instantiatedBounds(pre, owner, tparams, targs) + var bounds = instantiatedBounds(pre, owner, tparams, targs) + if (targs.exists(_.annotations.nonEmpty)) + bounds = adaptBoundsToAnnotations(bounds, tparams, targs) (bounds corresponds targs)(_ containsType _) // @PP: corresponds } |