Yield as contextual keyword
John Rose
john.r.rose at oracle.com
Sat May 25 20:22:45 UTC 2019
This one is fixable with a local-variable rename.
I think that's a robust solution as long as the
anonymous class is in a context where the
local can be introduced nearby.
We can perhaps find awkward contexts where
the local cannot be introduced. I'm thinking
of 'super(new Object() {…})' and field initializers.
In those cases, the outer object can supply
a field or method to provide access to the
shadowed 'this'.
On May 24, 2019, at 11:15 PM, Tagir Valeev <amaembo at gmail.com> wrote:
>
>
> var x = new Runnable() {
> public void run() {
+ var this1 = this;
> new Object() {
> void foo() {
+ this1.
> yield(1); // this.yield(1) or Runnable.this.yield(1) are incorrect.
> }
> }.foo();
> }
> void yield(int x) { System.out.println(x); }
> };
More information about the amber-spec-experts
mailing list