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

Overriding an abstract getter with a final field generates incorrect code #280

Closed
jmesserly opened this issue Nov 1, 2011 · 3 comments
Closed
Milestone

Comments

@jmesserly
Copy link

We're using this pattern in the compiler:

class VarMember {
  abstract String get name();
  ...
}

class VarFunctionStub extends VarMember {
  final String name;
  ...
}

The code generated for this is incorrect. It tries to create a "name" property on VarMember, which looks like:
Object.defineProperty(VarMember.prototype, "name", {
  get: VarMember.prototype.get$name,
});
Except get$name doesn't exist on the base class. Also, this prevents the setters on the derived classes from working (e.g. "this.name = name;" in VarFunctionStub ctor).

At this point you might be wondering: why isn't the self-hosted compiler currently broken? It is not broken! Probably because we don't use ".name" dynamically. This bug is only triggered when the compiler is used in the same codebase as DOM (or html?) libraries.

@vsmenon
Copy link
Member

vsmenon commented Nov 10, 2011

I'm seeing similar problems when the getter is not abstract:

class A {
  int get x() => null;
}

class B extends A {
  int x;
}

Setting the value x in the derived class is not working for me.

@dgrove
Copy link
Contributor

dgrove commented Nov 29, 2011

Added this to the FrogEditor milestone.

@dgrove
Copy link
Contributor

dgrove commented Nov 30, 2011

as of r1908, both of these examples are working correctly.


Added Fixed label.

@jmesserly jmesserly added this to the FrogEditor milestone Nov 30, 2011
nex3 pushed a commit that referenced this issue Aug 31, 2016
this also implements multitest support, which fixes #280

Fixes some other preexisting bugs:
* MetaLets did not simplify themselves correctly in some nested cases
* Library prefixed identifiers did not work as lvalues in opassign
* dsetindex/dput/[]= methods did not return a value
* checker did not correctly handle invalid constructor field initializers
* cascades did not correctly work with method invocations(?)
* postfix ++/-- did not correctly generate lvalues in some cases

The good news: because this reuses on our existing lvalue/metalet helpers, it managed to flush out a lot of bugs in other features that use them.

[email protected]

Review URL: https://codereview.chromium.org/1316723003 .
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants