-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label
Description
Compiler version
3.8.0
Minimized code
J.java
import java.util.*;
public class J {
public List<String> listS(String s) {
return new ArrayList<T>();
}
}S.scala
import java.util.List
class S {
def LList(s: String): List[String | Null] = (new J).listS("") // error
}scalac local/J.java local/S.scala -Yexplicit-nulls
Output
-- [E007] Type Mismatch Error: local/S.scala:4:59 ------------------------------
4 | def LList(s: String): List[String | Null] = (new J).listS("") // error
| ^^^^^^^^^^^^^^^^^
| Found: (java.util.List[String])?
| Required: java.util.List[String | Null]
|
| longer explanation available when compiling with `-explain`Expectation
It should be allowed, since the List actually does contain nullable Strings.
Even though the methods of List will be nullified at the call site, this example can extend to other generic Java types where it may even be necessary for the type parameter to be explicitly nullable.
Metadata
Metadata
Assignees
Labels
itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label