Skip to content

Commit

Permalink
Generate static forwarders for object members in companion interface
Browse files Browse the repository at this point in the history
Same change implemented five years ago in Scala 2:
scala/scala#5131

Fixes scala#13572.
  • Loading branch information
smarter committed Sep 21, 2021
1 parent 3a6a949 commit a8b1ee5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
emitAnnotations(cnode, claszSymbol.annotations ++ ssa)

if (!isCZStaticModule && !isCZParcelable) {
val skipStaticForwarders = (claszSymbol.isInterface || claszSymbol.is(Module) || ctx.settings.XnoForwarders.value)
val skipStaticForwarders = (claszSymbol.is(Module) || ctx.settings.XnoForwarders.value)
if (!skipStaticForwarders) {
val lmoc = claszSymbol.companionModule
// add static forwarders if there are no name conflicts; see bugs #363 and #1735
Expand Down
6 changes: 5 additions & 1 deletion compiler/test/dotc/run-test-pickling.blacklist
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Many of these tests fail because CompilationTests.pickling does not handle
## tests containing java files correctly

derive-generic.scala
eff-dependent.scala
enum-java
Expand Down Expand Up @@ -36,4 +39,5 @@ zero-arity-case-class.scala
i12194.scala
i12753
t6138
t6138-2
t6138-2
trait-static-forwarder
1 change: 1 addition & 0 deletions tests/run/trait-static-forwarder.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
5 changes: 5 additions & 0 deletions tests/run/trait-static-forwarder/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public final class Test {
public static void main(String... args) {
System.out.println(T.foo());
}
}
5 changes: 5 additions & 0 deletions tests/run/trait-static-forwarder/forwarders.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait T

object T {
def foo = 42
}

0 comments on commit a8b1ee5

Please sign in to comment.