scala3
scala3 copied to clipboard
Adding instance method causes static forwarder to disappear
Compiler version
3.6.0-RC1-bin-20241003-a672e05-NIGHTLY
Minimized code
class Foo {
// def bar(baz: Int): Int = ???
}
object Foo {
def bar(baz: String): String = ???
}
Output
Before
/*
* Decompiled with CFR 0.151.
*/
public class Foo {
public static String bar(String string) {
return Foo$.MODULE$.bar(string);
}
}
After
/*
* Decompiled with CFR 0.151.
*
* Could not load the following classes:
* scala.Predef$
*/
import scala.Predef$;
public class Foo {
public int bar(int baz) {
throw Predef$.MODULE$.$qmark$qmark$qmark();
}
}
Expectation
As far as I know the instance method and static method should be able to co-exist.
No they cannot coexist. It's a JVM limitation.
Different signatures, however.
No they cannot coexist. It's a JVM limitation.
This compiles for me.
class Foo {
public int bar(int baz) {
return 42;
}
public static String bar(String baz) {
return "static";
}
}