Open
Description
Compiler version
3.6.4
Minimized code
class Compiler(c: Int)
@main def test = println:
Compiler(42)
Output
➜ snips scala-cli compile --server=false -S 3.7.0-RC1 --jvm 17 no-compiler.scala
-- [E177] Reference Error: /home/amarki/snips/no-compiler.scala:5:2 ------------
5 | Compiler(42)
| ^^^^^^^^
| Reference to constructor proxy for class Compiler
| shadows outer reference to object Compiler in package java.lang
|
| The instance needs to be created with an explicit `new`.
|
| longer explanation available when compiling with `-explain`
1 error found
Compilation failed
Expectation
The API was deleted in modern JVMs, so this particular issue is resolved. However, we needn't be exposed to such brittleness.
-Yimports
is too blunt an instrument.
It doesn't matter if I
import java.lang.{Compiler as _, *}
which is one of those clever Scala things which may or may not work. Maybe it would work for a Predef
.
Maybe a directive could be used to unimport or shadow or otherwise specify a "profile" to compile against.
Noticed IRL at #17563 (comment)