diff options
author | Paul Phillips <paulp@improving.org> | 2011-11-24 02:01:00 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-11-24 02:01:00 +0000 |
commit | 2b069593c84194e21f88b8552ad12917decc14d5 (patch) | |
tree | 9d37331201d02b6cd9c5b11c742957c738bb4e16 /src/compiler/scala/reflect | |
parent | 93717598b711a69822d802e06873ed7b00f89898 (diff) | |
download | scala-2b069593c84194e21f88b8552ad12917decc14d5.tar.gz scala-2b069593c84194e21f88b8552ad12917decc14d5.tar.bz2 scala-2b069593c84194e21f88b8552ad12917decc14d5.zip |
Minor restructuring in Implicits.
Another case where I tried to get into the performance party but ended
up playing dungeons and dragons next door. However I did come away with
an attractive tablecloth, which I draped over Implicits.scala before
waving my magic wand.
TRANSLATION: it's probably not faster but it's still better.
Diffstat (limited to 'src/compiler/scala/reflect')
-rw-r--r-- | src/compiler/scala/reflect/internal/Definitions.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/reflect/internal/Symbols.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 12 |
3 files changed, 17 insertions, 7 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 5802174a5b..092c478bef 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -72,10 +72,11 @@ trait Definitions extends reflect.api.StandardDefinitions { clazz } - def isNumericSubClass(sub: Symbol, sup: Symbol) = { - val cmp = for (w1 <- numericWeight get sub ; w2 <- numericWeight get sup) yield w2 % w1 - cmp exists (_ == 0) - } + def isNumericSubClass(sub: Symbol, sup: Symbol) = ( + (numericWeight contains sub) + && (numericWeight contains sup) + && (numericWeight(sup) % numericWeight(sub) == 0) + ) /** Is symbol a numeric value class? */ def isNumericValueClass(sym: Symbol): Boolean = diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 1b1d26d038..65b60bfa39 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -1250,6 +1250,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def isNumericSubClass(that: Symbol): Boolean = definitions.isNumericSubClass(this, that) + final def isWeakSubClass(that: Symbol) = + isSubClass(that) || isNumericSubClass(that) + // ------ overloaded alternatives ------------------------------------------------------ def alternatives: List[Symbol] = diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 0f8d28ff03..a69db8e0f4 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -5559,9 +5559,15 @@ A type's typeSymbol should never be inspected directly. isSubType(tp1, tp2) } - def isNumericSubType(tp1: Type, tp2: Type) = - isNumericValueType(tp1) && isNumericValueType(tp2) && - isNumericSubClass(tp1.typeSymbol, tp2.typeSymbol) + /** The isNumericValueType tests appear redundant, but without them + * test/continuations-neg/function3.scala goes into an infinite loop. + * (Even if the calls are to typeSymbolDirect.) + */ + def isNumericSubType(tp1: Type, tp2: Type) = ( + isNumericValueType(tp1) + && isNumericValueType(tp2) + && isNumericSubClass(tp1.typeSymbol, tp2.typeSymbol) + ) private val lubResults = new mutable.HashMap[(Int, List[Type]), Type] private val glbResults = new mutable.HashMap[(Int, List[Type]), Type] |