summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-02-20 15:31:32 -0800
committerJames Iry <jamesiry@gmail.com>2013-02-21 09:02:37 -0800
commit1b6661b8b586637ba5d54510c7bda1144acab23b (patch)
tree8abb70e9fd764f4dd4aff09dd12c015cdd723fdf /src/library
parent70956e560a11996e1d801d59b312dfe9d56b7a74 (diff)
downloadscala-1b6661b8b586637ba5d54510c7bda1144acab23b.tar.gz
scala-1b6661b8b586637ba5d54510c7bda1144acab23b.tar.bz2
scala-1b6661b8b586637ba5d54510c7bda1144acab23b.zip
SI-7015 Removes redundant aconst_null; pop; aconst_null creation
In an effort to adapt methods and field accesses of type Null to other types, we were always emitting aconst_null pop aconst_null The problem is we were doing that even when the JVM was in a position to know it had null value, e.g. when the user had written a null constant. This commit fixes that and includes a test to show that the resulting byte code still works even without repeating ourselves and/or repeating ourselves. This commit also makes the scala.runtim.Null$ constructor private. It was a sealed abstract class which prevented subclassing in Scala, but it didn't prevent subclassing in Java. A private constructor takes care of that hole so now the only value of type Null$ should be null. Along the way I found some other questionable things in adapt and I've added TODO's and issue https://issues.scala-lang.org/browse/SI-7159 to track.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/runtime/Null$.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala
index 797b31583d..25b797a606 100644
--- a/src/library/scala/runtime/Null$.scala
+++ b/src/library/scala/runtime/Null$.scala
@@ -11,6 +11,7 @@ package scala.runtime
/**
* Dummy class which exist only to satisfy the JVM. It corresponds to
* `scala.Null`. If such type appears in method signatures, it is erased
- * to this one.
+ * to this one. A private constructor ensures that Java code can't create
+ * subclasses. The only value of type Null$ should be null
*/
-sealed abstract class Null$
+sealed abstract class Null$ private ()