Skip to content

REPL compiler crash IllegalArgumentException when declaring collective extensions 2 defs and then same names as 2 vals #19184

Closed
@bjornregnell

Description

@bjornregnell

Compiler version

3.3.1 and 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY

Minimized code + Output

$ scala-cli -S 3.nightly
Downloading Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY compiler
Welcome to Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY-git-d96e9e4 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                              
scala> extension (s: String) 
     |   def o = s + "o"
     |   def oo = s + "oo"
     | val o = "o"
     | val oo = "oo"
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at dotty.tools.repl.Rendering.$anonfun$4(Rendering.scala:110)
    at scala.Option.flatMap(Option.scala:283)
    at dotty.tools.repl.Rendering.valueOf(Rendering.scala:110)
    at dotty.tools.repl.Rendering.renderVal(Rendering.scala:152)
    at dotty.tools.repl.ReplDriver.$anonfun$7(ReplDriver.scala:390)
    at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
    at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
    at scala.collection.immutable.List.foreach(List.scala:333)

Expectation

The compiler should not crash. The code should work just as in:

$ scala-cli -S 3.nightly
Welcome to Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY-git-d96e9e4 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                              
scala> extension (s: String) 
     |   def oo = s + "oo"
     | val oo = "oo"
def oo(s: String): String
val oo: String = oo

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions