Skip to content

Forwarding stubs should not forward to other forwarding stubs #31580

Closed
@stereotype441

Description

@stereotype441

Consider the following code:

class A {}
class B extends A {}
class C {
  void f(B x, B y) {}
}
abstract class I1 {
  void f(covariant A x, B y);
}
class D extends C implements I1 {}
abstract class I2 {
  void f(B x, covariant A y);
}
class E extends D implements I2 {}

During compilation of class D, the front end discovers that it needs to insert a forwarding stub for f to ensure that x is type checked. This forwarding stub forwards to C::f. During compilation of class E, the front end discovers that it needs to insert a forwarding stub for f to ensure that y is also type checked. This forwarding stub should forward directly to C::f--it shouldn't forward to D::f.

Note that the front end currently does this correctly provided that D and E are being compiled at the same time. But in a modular compilation scenario where E is being compiled and D comes from a .dill file, the front end tries to forward E::f to D::f.

(Borrowing terminology from #31562 (comment), the target in question here is the "super target")

CC: @sjindel-google

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions