diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-29 07:54:59 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-29 10:49:32 -0800 |
commit | eba079b6522cc112d949c1f2c18960e31750efd6 (patch) | |
tree | cbfd753db3d8a8c6f783210d816e9d1bf8886775 | |
parent | eff78b852e8b866badf9b9738f896c2a31c05474 (diff) | |
download | scala-eba079b6522cc112d949c1f2c18960e31750efd6.tar.gz scala-eba079b6522cc112d949c1f2c18960e31750efd6.tar.bz2 scala-eba079b6522cc112d949c1f2c18960e31750efd6.zip |
Optimization in AsSeenFromMap.
Despite all the eyes which have traveled over this code,
we all managed to miss this:
// Note that pre and clazz are fixed at construction
class AsSeenFromMap(pre: Type, clazz: Symbol) {
...
def apply(tp: Type): Type =
if (skipPrefixOf(pre, clazz)) tp
else ...
}
Additionally, the exclusion condition in asSeenFrom contained
a useless check, here:
// !isPossiblePrefix(clazz) alone is enough
pre.normalize.isTrivial && !isPossiblePrefix(clazz)
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index d0c9b8dd03..a2b3fd5d97 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -746,7 +746,7 @@ trait Types extends api.Types { self: SymbolTable => val trivial = ( this.isTrivial || phase.erasedTypes && pre.typeSymbol != ArrayClass - || pre.normalize.isTrivial && !isPossiblePrefix(clazz) + || skipPrefixOf(pre, clazz) ) if (trivial) this else { @@ -4471,14 +4471,15 @@ trait Types extends api.Types { self: SymbolTable => */ def isPossiblePrefix(clazz: Symbol) = clazz.isClass && !clazz.isPackageClass + private def skipPrefixOf(pre: Type, clazz: Symbol) = ( + (pre eq NoType) || (pre eq NoPrefix) || !isPossiblePrefix(clazz) + ) + /** A map to compute the asSeenFrom method */ class AsSeenFromMap(pre: Type, clazz: Symbol) extends TypeMap with KeepOnlyTypeConstraints { var capturedSkolems: List[Symbol] = List() var capturedParams: List[Symbol] = List() - private def skipPrefixOf(pre: Type, clazz: Symbol) = ( - (pre eq NoType) || (pre eq NoPrefix) || !isPossiblePrefix(clazz) - ) override def mapOver(tree: Tree, giveup: ()=>Nothing): Tree = { object annotationArgRewriter extends TypeMapTransformer { private def canRewriteThis(sym: Symbol) = ( @@ -4511,8 +4512,7 @@ trait Types extends api.Types { self: SymbolTable => } def apply(tp: Type): Type = - if (skipPrefixOf(pre, clazz)) tp - else tp match { + tp match { case ThisType(sym) => def toPrefix(pre: Type, clazz: Symbol): Type = if (skipPrefixOf(pre, clazz)) tp |