Skip to content
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

noSuchMethod forwarders shouldn't be generated in abstract classes, but rather in their concrete descendants #33482

Closed
chloestefantsova opened this issue Jun 18, 2018 · 1 comment
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on

Comments

@chloestefantsova
Copy link
Contributor

Consider the following code:

abstract class Hest {
  noSuchMethod(i) => null;

  void hest();
}

class Fisk extends Hest {}

main() {}

Currently, it's compiled to the following Kernel code:

library;
import self as self;
import "dart:core" as core;

abstract class Hest extends core::Object {
  synthetic constructor •() → void
    : super core::Object::•()
    ;
  method noSuchMethod(core::Invocation i) → dynamic
    return null;
  no-such-method-forwarder method hest() → void
    return this.{self::Hest::noSuchMethod}(new core::_InvocationMirror::_withoutType("hest", const <core::Type>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{}), false));
}
class Fisk extends self::Hest {
  synthetic constructor •() → void
    : super self::Hest::•()
    ;
}
static method main() → dynamic {}

Note that the abstract class gets the noSuchMethod forwarder, and the concrete child inherits it. However, abstract classes shouldn't receive noSuchMethod forwarders for their abstract members, even if those classes have a user-defined noSuchMethod. The forwarders should be added to the top-most concrete descendants of such abstract classes. In the example above, it's Hest that should receive the forwarder.

@chloestefantsova chloestefantsova added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Jun 18, 2018
@chloestefantsova chloestefantsova self-assigned this Jun 18, 2018
@chloestefantsova chloestefantsova added the P2 A bug or feature request we're likely to work on label Jun 18, 2018
@jensjoha jensjoha added this to Triaged in Dart Front End Jun 26, 2018
@chloestefantsova
Copy link
Contributor Author

Fixed as of 6db5f38.

@kmillikin kmillikin moved this from Triaged to Done in Dart Front End Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on
Projects
Development

No branches or pull requests

1 participant