Skip to content

Commit a8b1ee5

Browse files
committed
Generate static forwarders for object members in companion interface
Same change implemented five years ago in Scala 2: scala/scala#5131 Fixes #13572.
1 parent 3a6a949 commit a8b1ee5

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
292292
emitAnnotations(cnode, claszSymbol.annotations ++ ssa)
293293

294294
if (!isCZStaticModule && !isCZParcelable) {
295-
val skipStaticForwarders = (claszSymbol.isInterface || claszSymbol.is(Module) || ctx.settings.XnoForwarders.value)
295+
val skipStaticForwarders = (claszSymbol.is(Module) || ctx.settings.XnoForwarders.value)
296296
if (!skipStaticForwarders) {
297297
val lmoc = claszSymbol.companionModule
298298
// add static forwarders if there are no name conflicts; see bugs #363 and #1735

compiler/test/dotc/run-test-pickling.blacklist

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Many of these tests fail because CompilationTests.pickling does not handle
2+
## tests containing java files correctly
3+
14
derive-generic.scala
25
eff-dependent.scala
36
enum-java
@@ -36,4 +39,5 @@ zero-arity-case-class.scala
3639
i12194.scala
3740
i12753
3841
t6138
39-
t6138-2
42+
t6138-2
43+
trait-static-forwarder
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public final class Test {
2+
public static void main(String... args) {
3+
System.out.println(T.foo());
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
trait T
2+
3+
object T {
4+
def foo = 42
5+
}

0 commit comments

Comments
 (0)