Skip to content

Fix #8936: Correct generic signature for Nothing/Null #8943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,11 @@ class Definitions {
@tu lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
def NothingType: TypeRef = NothingClass.typeRef
@tu lazy val RuntimeNothingModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Nothing")
@tu lazy val NullClass: ClassSymbol = {
val parent = if (ctx.explicitNulls) AnyType else ObjectType
enterCompleteClassSymbol(ScalaPackageClass, tpnme.Null, AbstractFinal, parent :: Nil)
}
def NullType: TypeRef = NullClass.typeRef
@tu lazy val RuntimeNullModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Null")

/** An alias for null values that originate in Java code.
* This type gets special treatment in the Typer. Specifically, `UncheckedNull` can be selected through:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ object GenericSignatures {
else if (sym == defn.UnitClass || sym == defn.BoxedUnitModule)
jsig(defn.BoxedUnitClass.typeRef)
else if (sym == defn.NothingClass)
jsig(defn.RuntimeNothingModuleRef)
builder.append("Lscala/runtime/Nothing$;")
else if (sym == defn.NullClass)
jsig(defn.RuntimeNullModuleRef)
builder.append("Lscala/runtime/Null$;")
else if (sym.isPrimitiveValueClass)
if (!primitiveOK) jsig(defn.ObjectType)
else if (sym == defn.UnitClass) jsig(defn.BoxedUnitClass.typeRef)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos-java-interop/i8936/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class A {
def no: List[Nothing] = Nil
}
8 changes: 8 additions & 0 deletions tests/pos-java-interop/i8936/B.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.collection.immutable.List;

class B {
void Nothingness(){
A a = new A();
List<scala.runtime.Nothing$> strings = a.no();
}
}