diff options
author | Paul Phillips <paulp@improving.org> | 2011-06-21 17:20:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-06-21 17:20:51 +0000 |
commit | 4b8810d3a35bca001ccde28c24ea3000c3b47a07 (patch) | |
tree | ebe21b734d458fe57604de601ca1f06bef258213 | |
parent | 5c416166c22abfb5ca0a595b468844708dcdaa45 (diff) | |
download | scala-4b8810d3a35bca001ccde28c24ea3000c3b47a07.tar.gz scala-4b8810d3a35bca001ccde28c24ea3000c3b47a07.tar.bz2 scala-4b8810d3a35bca001ccde28c24ea3000c3b47a07.zip |
Documented what happened with the implementatio...
Documented what happened with the implementation of narrow for future
performance detectives. No review.
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 43694dfb82..ed5dd1bc72 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -79,8 +79,6 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable => private var explainSwitch = false private final val emptySymbolSet = immutable.Set.empty[Symbol] - private final val alternativeNarrow = false - private final val LogPendingSubTypesThreshold = 50 private final val LogPendingBaseTypesThreshold = 50 private final val LogVolatileThreshold = 50 @@ -333,21 +331,31 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable => def typeOfThis: Type = typeSymbol.typeOfThis /** Map to a singleton type which is a subtype of this type. + * The fallback implemented here gives + * T.narrow = T' forSome { type T' <: T with Singleton } + * Overridden where we know more about where types come from. + */ + /* + Note: this implementation of narrow is theoretically superior to the one + in use below, but imposed a significant performance penalty. It was in trunk + from svn r24960 through r25080. + */ + /* + def narrow: Type = + if (phase.erasedTypes) this + else commonOwner(this) freshExistential ".type" setInfo singletonBounds(this) tpe + */ + + /** Map to a singleton type which is a subtype of this type. * The fallback implemented here gives: * {{{ * T.narrow = (T {}).this.type * }}} * Overridden where we know more about where types come from. - * - * todo: change to singleton type of an existentially defined variable - * of the right type instead of making this a `this` of a refined type. */ def narrow: Type = if (phase.erasedTypes) this - else if (alternativeNarrow) { // investigate why this does not work! - val tparam = commonOwner(this) freshExistential ".type" setInfo singletonBounds(this) - tparam.tpe - } else { + else { val cowner = commonOwner(this) refinedType(List(this), cowner, EmptyScope, cowner.pos).narrow } |