summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-11 20:32:35 +0000
committerPaul Phillips <paulp@improving.org>2011-06-11 20:32:35 +0000
commit581a8c6ffe558c6fb2fc44239c13db6eec8be968 (patch)
tree0f92f81d5da6b71daf43a5ef7d4442bd0eebbdc3 /src/compiler/scala/reflect/internal/Types.scala
parent8bba6eb9d36255754c183f805c4e283de8667da8 (diff)
downloadscala-581a8c6ffe558c6fb2fc44239c13db6eec8be968.tar.gz
scala-581a8c6ffe558c6fb2fc44239c13db6eec8be968.tar.bz2
scala-581a8c6ffe558c6fb2fc44239c13db6eec8be968.zip
A few additional (but less dramatic) optimizati...
A few additional (but less dramatic) optimizations to implicit search, courtesy of Tiark. No review.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 7db76fbf59..1459371349 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -860,7 +860,7 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable =>
*/
//TODO: use narrow only for modules? (correct? efficiency gain?)
def findMember(name: Name, excludedFlags: Long, requiredFlags: Long, stableOnly: Boolean): Symbol = {
- val suspension = TypeVar.Suspension
+ var suspension: mutable.HashSet[TypeVar] = null
// if this type contains type variables, put them to sleep for a while -- don't just wipe them out by
// replacing them by the corresponding type parameter, as that messes up (e.g.) type variables in type refinements
// without this, the matchesType call would lead to type variables on both sides
@@ -877,9 +877,10 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable =>
// For now I modified it as below, which achieves the same without error.
//
// make each type var in this type use its original type for comparisons instead of collecting constraints
+ suspension = new mutable.HashSet
this foreach {
- case tv: TypeVar => suspension suspend tv
- case _ => ()
+ case tv: TypeVar => tv.suspended = true; suspension += tv
+ case _ =>
}
}
@@ -912,7 +913,7 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable =>
(bcs0.head.hasTransOwner(bcs.head)))) {
if (name.isTypeName || stableOnly && sym.isStable) {
stopTimer(findMemberNanos, start)
- suspension.resumeAll
+ if (suspension ne null) suspension foreach (_.suspended = false)
return sym
} else if (member == NoSymbol) {
member = sym
@@ -954,7 +955,7 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable =>
excluded = excludedFlags
} // while (continue)
stopTimer(findMemberNanos, start)
- suspension.resumeAll
+ if (suspension ne null) suspension foreach (_.suspended = false)
if (members eq null) {
if (member == NoSymbol) incCounter(noMemberCount)
member
@@ -2317,6 +2318,7 @@ A type's typeSymbol should never be inspected directly.
object TypeVar {
// encapsulate suspension so we can automatically link the suspension of cloned
// typevars to their original if this turns out to be necessary
+/*
def Suspension = new Suspension
class Suspension {
private val suspended = mutable.HashSet[TypeVar]()
@@ -2331,7 +2333,7 @@ A type's typeSymbol should never be inspected directly.
suspended.clear()
}
}
-
+*/
def unapply(tv: TypeVar): Some[(Type, TypeConstraint)] = Some((tv.origin, tv.constr))
def apply(origin: Type, constr: TypeConstraint) = new TypeVar(origin, constr, List(), List())
// TODO why not initialise TypeConstraint with bounds of tparam?
@@ -2402,7 +2404,7 @@ A type's typeSymbol should never be inspected directly.
// </region>
// ignore subtyping&equality checks while true -- see findMember
- private[TypeVar] var suspended = false
+ private[Types] var suspended = false
/** Called when a TypeVar is involved in a subtyping check. Result is whether
* this TypeVar could plausibly be a [super/sub]type of argument `tp` and if so,