Skip to content

[Backport] Generate static forwarders for object members in companion interface #13616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}