summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-21 17:20:51 +0000
committerPaul Phillips <paulp@improving.org>2011-06-21 17:20:51 +0000
commit4b8810d3a35bca001ccde28c24ea3000c3b47a07 (patch)
treeebe21b734d458fe57604de601ca1f06bef258213 /src
parent5c416166c22abfb5ca0a595b468844708dcdaa45 (diff)
downloadscala-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.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala26
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
}