From 1b6661b8b586637ba5d54510c7bda1144acab23b Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 20 Feb 2013 15:31:32 -0800 Subject: 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. --- src/library/scala/runtime/Null$.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/library') 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 () -- cgit v1.2.3