Skip to content

Commit 4af166a

Browse files
committed
Fix #8936: Correct generic signature for Nothing/Null
The runtime classes are called "scala.runtime.Nothing$" and "scala.runtime.Null$", but the signatures were missing the dollar at the end. Since these two types are special anyway, we can just emit their signature directly and not bother with loading their classfiles.
1 parent 3937ddb commit 4af166a

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,11 @@ class Definitions {
355355
@tu lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
356356
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
357357
def NothingType: TypeRef = NothingClass.typeRef
358-
@tu lazy val RuntimeNothingModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Nothing")
359358
@tu lazy val NullClass: ClassSymbol = {
360359
val parent = if (ctx.explicitNulls) AnyType else ObjectType
361360
enterCompleteClassSymbol(ScalaPackageClass, tpnme.Null, AbstractFinal, parent :: Nil)
362361
}
363362
def NullType: TypeRef = NullClass.typeRef
364-
@tu lazy val RuntimeNullModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Null")
365363

366364
/** An alias for null values that originate in Java code.
367365
* This type gets special treatment in the Typer. Specifically, `UncheckedNull` can be selected through:

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ object GenericSignatures {
202202
else if (sym == defn.UnitClass || sym == defn.BoxedUnitModule)
203203
jsig(defn.BoxedUnitClass.typeRef)
204204
else if (sym == defn.NothingClass)
205-
jsig(defn.RuntimeNothingModuleRef)
205+
builder.append("Lscala/runtime/Nothing$;")
206206
else if (sym == defn.NullClass)
207-
jsig(defn.RuntimeNullModuleRef)
207+
builder.append("Lscala/runtime/Null$;")
208208
else if (sym.isPrimitiveValueClass)
209209
if (!primitiveOK) jsig(defn.ObjectType)
210210
else if (sym == defn.UnitClass) jsig(defn.BoxedUnitClass.typeRef)

tests/pos-java-interop/i8936/A.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class A {
2+
def no: List[Nothing] = Nil
3+
}

tests/pos-java-interop/i8936/B.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.collection.immutable.List;
2+
3+
class B {
4+
void Nothingness(){
5+
A a = new A();
6+
List<scala.runtime.Nothing$> strings = a.no();
7+
}
8+
}

0 commit comments

Comments
 (0)