-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:jdkIssues tied to artifacts published under a particular jdkIssues tied to artifacts published under a particular jdkcompat:javaitype:bugitype:crash
Description
Based on OpenCB failure in getkyo/kyo - build logs
When a Scala 3 library (ox) is published using JDK 21 and uses API introduced in this version, usage of this artifact in other project using lower JDK version (kyo) would lead to compiler crash. The crash message contains phrase the classfile defining the type might be missing from the classpath - however we should try to handle the crash using error reporting instead of uncontrolled failure. Scala 2.13 does not crash at compile time, but rather fails at runtime
Compiler version
All Scala 3 versions
Minimized code
// defs_1.scala
//> using jvm 21
package ox
import java.util.concurrent.StructuredTaskScope
trait Ox {
def scope: StructuredTaskScope[Any]
}// usage_2.scala
//> using jvm 8
given ox.Ox = ???Output
> scala-cli compile *.scala --test -S 3 --server=false
Warning: setting /Users/wmazur/projects/sandbox as the project root directory for this run.
unhandled exception while running MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, etaReduce, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars} on /Users/wmazur/projects/sandbox/test.test.scala
An unhandled exception was thrown in the compiler.
Please file a crash report here:
https://github.com/scala/scala3/issues/new/choose
For non-enriched exceptions, compile with -Yno-enrich-error-messages.
while compiling: /Users/wmazur/projects/sandbox/test.test.scala
during phase: MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, etaReduce, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}
mode: Mode(ImplicitsEnabled)
library version: version 2.13.12
compiler version: version 3.4.2
settings: -classpath /Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.2/scala3-library_3-3.4.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/wmazur/projects/sandbox/.scala-build/sandbox_81ef297d4b_37166ea454-6e667bf95c/classes/main:/Users/wmazur/projects/sandbox/.scala-build/sandbox_81ef297d4b_37166ea454-6e667bf95c/classes/main -d /Users/wmazur/projects/sandbox/.scala-build/sandbox_81ef297d4b_37166ea454-6e667bf95c/classes/test -sourceroot /Users/wmazur/projects/sandbox
cannot resolve reference to type java.util.concurrent.type.StructuredTaskScope
the classfile defining the type might be missing from the classpath
Compilation failedExpectation
Compiler should provide meaningful message about incompatible JDK.
In Scala 2.13 it compiles but fails at runtime.
SethTisue, He-Pin and tanishiking
Metadata
Metadata
Assignees
Labels
area:jdkIssues tied to artifacts published under a particular jdkIssues tied to artifacts published under a particular jdkcompat:javaitype:bugitype:crash