java higher-kind interop fails with dotty #16797
-
let's consider the following trait HigherKind[C[_]] And public class JHigherKindWrapper {
private HigherKind<java.util.List> underlying;
} This used to compile with scala
Why is dotty failing compilation in this case ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Java doesn't have higher-kinded types: while you can write I'm not sure why it doesn't happen in Scala 2 though. What's your usecase? If the Scala code doesn't depend on the Java code, you could set up your build tool so the Scala compiler doesn't see the Java code at all (in sbt: |
Beta Was this translation helpful? Give feedback.
Java doesn't have higher-kinded types: while you can write
java.util.List
without passing type arguments to it, it is equivalent tojava.util.List<?>
(it's a raw type). When compiling a mixed java/scala project, the Scala compiler also typechecks Java sources, so it will error out onHigkerKind<java.util.List>
which it will interpret as the Scala typeHigherKind[java.util.List[?]]
.I'm not sure why it doesn't happen in Scala 2 though. What's your usecase? If the Scala code doesn't depend on the Java code, you could set up your build tool so the Scala compiler doesn't see the Java code at all (in sbt:
compileOrder := CompileOrder.ScalaThenJava
)