aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-03-26 09:40:20 +0100
committerodersky <odersky@gmail.com>2015-03-26 09:40:20 +0100
commitc5d8cba234ace613f5b064fc3cc58c8e547e45ce (patch)
tree4b1765def56fb344bf22a9090e288bddee427f69 /src
parented1de3a26e00e5b7f4113ce32fa00c2f992deafa (diff)
parentd058f98ddc5790b5b3050f6dd10d5d4c84d4eda6 (diff)
downloaddotty-c5d8cba234ace613f5b064fc3cc58c8e547e45ce.tar.gz
dotty-c5d8cba234ace613f5b064fc3cc58c8e547e45ce.tar.bz2
dotty-c5d8cba234ace613f5b064fc3cc58c8e547e45ce.zip
Merge pull request #425 from smarter/fix/isNullableClass
Fix isNullableClass to also work after Erasure
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala13
-rw-r--r--src/dotty/tools/dotc/transform/ValueClasses.scala10
2 files changed, 12 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index bc253021f..dabdf54af 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -496,13 +496,18 @@ object SymDenotations {
*/
def derivesFrom(base: Symbol)(implicit ctx: Context) = false
- /** Is this symbol a class that does not extend `AnyVal`? */
- final def isNonValueClass(implicit ctx: Context): Boolean =
- isClass && !derivesFrom(defn.AnyValClass) && (symbol ne defn.NothingClass)
+ /** Is this symbol a class that extends `AnyVal`? */
+ final def isValueClass(implicit ctx: Context): Boolean = {
+ val di = this.initial.asSymDenotation
+ di.isClass &&
+ di.derivesFrom(defn.AnyValClass)(ctx.withPhase(di.validFor.firstPhaseId))
+ // We call derivesFrom at the initial phase both because AnyVal does not exist
+ // after Erasure and to avoid cyclic references caused by forcing denotations
+ }
/** Is this symbol a class references to which that are supertypes of null? */
final def isNullableClass(implicit ctx: Context): Boolean =
- isNonValueClass && !(this is ModuleClass)
+ isClass && !isValueClass && !(this is ModuleClass)
/** Is this definition accessible as a member of tree with type `pre`?
* @param pre The type of the tree from which the selection is made
diff --git a/src/dotty/tools/dotc/transform/ValueClasses.scala b/src/dotty/tools/dotc/transform/ValueClasses.scala
index 276385b0b..ab4bba94e 100644
--- a/src/dotty/tools/dotc/transform/ValueClasses.scala
+++ b/src/dotty/tools/dotc/transform/ValueClasses.scala
@@ -12,13 +12,9 @@ import Flags._
object ValueClasses {
def isDerivedValueClass(d: SymDenotation)(implicit ctx: Context) = {
- val di = d.initial.asSymDenotation
- di.isClass &&
- di.derivesFrom(defn.AnyValClass)(ctx.withPhase(di.validFor.firstPhaseId)) &&
- // need to check derivesFrom at initialPhase to avoid cyclic references caused
- // by forcing in transformInfo
- (di.symbol ne defn.AnyValClass) &&
- !di.isPrimitiveValueClass
+ d.isValueClass &&
+ (d.initial.symbol ne defn.AnyValClass) && // Compare the initial symbol because AnyVal does not exist after erasure
+ !d.isPrimitiveValueClass
}
def isMethodWithExtension(d: SymDenotation)(implicit ctx: Context) =