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

cannot access superclass from local function #3197

Closed
peter-ahe-google opened this issue May 24, 2012 · 7 comments
Closed

cannot access superclass from local function #3197

peter-ahe-google opened this issue May 24, 2012 · 7 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@peter-ahe-google
Copy link
Contributor

The Dart VM fails to compile the program below (which I'll add as dart/tests/language/closure_with_super_send_test.dart in a CL later today).

The VM reports:

'file:///.../dart/tests/language/closure_with_super_send_test.dart': Error: line 16 pos 28: cannot access superclass from local function
    [0].forEach((e) => x = super.m());
                           ^

class Super {
  m() => "super";
}

class Sub extends Super {
  m() => "sub";

  test() {
    var x;
    [0].forEach((e) => x = super.m());
    return x;
  }
}

main() {
  Expect.equals("super", new Sub().test());
  Expect.equals("super", new Super().m());
  Expect.equals("sub", new Sub().m());
}

@jmesserly
Copy link

Yeah, even stranger: if you "closurize" a method that uses super, you get the same error. It's sort of like the method got expanded inline or something. If you change the closurization to a lambda that calls the function, then it works again.

@iposva-google
Copy link
Contributor

Set owner to @mhausner.
Added Accepted label.

@kevmoo
Copy link
Member

kevmoo commented Aug 22, 2012

I have an instance method baseclass._updateClock() which I pass into window.setInterval

At runtime, the call to super._updateClock() from subclass._updateClock() gives the same error

@DartBot
Copy link

DartBot commented Aug 28, 2012

This comment was originally written by peter.wih...@gmail.com


ugly workaround:
create a field in subclass that references your method

  Function superUpdate;

and initialize field in the subclass constructor

    superUpdate = super.update;

@DartBot
Copy link

DartBot commented Oct 23, 2012

This comment was originally written by @mhausner


Fixed in r13917.

@DartBot
Copy link

DartBot commented Oct 23, 2012

This comment was originally written by @mhausner


Added Fixed label.

@kevmoo
Copy link
Member

kevmoo commented Nov 14, 2012

Verified on r14973 (sorry, took me a while to update pop-pop-win)

Thanks!

@peter-ahe-google peter-ahe-google added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Nov 14, 2012
copybara-service bot pushed a commit that referenced this issue Oct 29, 2021
Changes:
```
> git log --format="%C(auto) %h %s" 78bc50c..0035a40
 https://dart.googlesource.com/pub.git/+/0035a40f Fix echo mode crash on `token add` (#3194)
 https://dart.googlesource.com/pub.git/+/a75a8c17 Don't warn against discontinued transitive dependencies (#3195)
 https://dart.googlesource.com/pub.git/+/cf2ed105 Fix analytics code (#3197)
 https://dart.googlesource.com/pub.git/+/08e13f7b Remove unused golden files (#3189)
 https://dart.googlesource.com/pub.git/+/b6293b80 Fix log message related to `pub global activate`  (#3187)
 https://dart.googlesource.com/pub.git/+/94f6b477 Introducing command-line interface tests (#3161)
 https://dart.googlesource.com/pub.git/+/3ba8134f More details from getExecutableForCommand (#3186)
 https://dart.googlesource.com/pub.git/+/a2dbcfff Shorthand syntax for hosted dependencies (#3133)
 https://dart.googlesource.com/pub.git/+/435e4e3f Shuffle analytics (#3185)

```

Diff: https://dart.googlesource.com/pub.git/+/78bc50c7833451c24e531713362e46fd50621ff0~..0035a40f25d027130c0314571da53ffafc6d973b/
Change-Id: Idfd7c382985d1ad3e3ad87a621dc79d3b74e898e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218620
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
copybara-service bot pushed a commit that referenced this issue Sep 29, 2022
…3 revisions)

https://dart.googlesource.com/dartdoc/+log/691fa9640aae..62bc1503b285

2022-09-28 srawlins@google.com Fix styles in inline search results (#3197)
2022-09-28 srawlins@google.com Simplify some code in dartdoc_options.dart (#3156)
2022-09-28 srawlins@google.com Prevent default when hitting enter (#3195)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/dart-doc-dart-sdk
Please CC dart-ecosystem-gardener@grotations.appspotmail.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Dart Documentation Generator: https://github.com/dart-lang/dartdoc/issues
To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Tbr: dart-ecosystem-gardener@grotations.appspotmail.com
Change-Id: I51527ab30a73a73de95f53715e83488562a54c71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261445
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

5 participants