bad option '-target:16' was ignored
when compiling scala code with Scala3 library
#20180
Labels
Milestone
'16' means Java 16.
The option passed to scala3 compiler contains invalid argument, '-target'
Expected Behavior
'-target:16' should be '-Xtarget:16', as described in here
Current Behavior
'-target:16' is passed to scala compiler and causes warning
Context
In scala 2.13.x, '-target:' option is valid. In scala3, the option is replaced to '-Xtarget:'(https://docs.scala-lang.org/scala3/guides/migration/options-lookup.html).
The option which will be passed to scala compiler is created in these codes.
gradle/subprojects/scala/src/main/java/org/gradle/api/internal/tasks/scala/ZincScalaCompiler.java
Lines 106 to 111 in 4f9c0e1
(#19864 seems to change code in ZincScalaCompiler but this issue may not be solved.)
The last
withJavacOptions
seems to add '-target:16' because it should be passed to javac, but '-target:16' is no longer valid option in scala3.If you set other parameters such as
-Wconf:cat=deprecation:w,any:e
, the warning changes to an error and the compilation fails.Steps to Reproduce
implementation(group: 'org.scala-lang', name: 'scala3-library_3', version: '3.1.2-RC2')
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
. In my code, I use Java 16 but the version does not matter.sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16
repo: https://github.com/Kotori316/gradle-issue-scala-option
Your Environment
The text was updated successfully, but these errors were encountered: