native icon indicating copy to clipboard operation
native copied to clipboard

Shadowing the type parameter in non-static nested classes

Open HosseinYousefi opened this issue 2 years ago • 0 comments

Say we have a nested class like:

public class A<T> {
  public class B<T> {
    // ...
  }
}

As far as I know, we cannot use the type parameter T (outer) inside B because T (inner) shadows it. So we can safely ignore the outer T.

  • [ ] TODO: verify the above.

However we generate the code for this wrong in the unnesting process:

class B<$T extends JObject, $T extends JObject> { /* ... */ }

We should only generate one of the type parameters, but also correctly differentiate between the two when inferring types.

HosseinYousefi avatar Jun 09 '23 00:06 HosseinYousefi