aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-03-23 23:16:17 +0100
committerGuillaume Martres <smarter@ubuntu.com>2015-03-23 23:23:54 +0100
commitd058f98ddc5790b5b3050f6dd10d5d4c84d4eda6 (patch)
treee7ae30c4c87c594513083c6f4c2daae52fab6a72 /src/dotty/tools/dotc/core/SymDenotations.scala
parentc6792189ff2075ac8b90efc7fad42aafd6a7b67e (diff)
downloaddotty-d058f98ddc5790b5b3050f6dd10d5d4c84d4eda6.tar.gz
dotty-d058f98ddc5790b5b3050f6dd10d5d4c84d4eda6.tar.bz2
dotty-d058f98ddc5790b5b3050f6dd10d5d4c84d4eda6.zip
Fix isNullableClass to also work after Erasure
Incidentally this means that: val d = null.asInstanceOf[Double] is now correctly transformed to: val d = scala.Double.unbox(null) Previously it was translated to: val d = null: Double Which is wrong and fails in the backend.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 44629c036..62e9ab0d2 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