Skip to content

Feature/1782 paramaterized enclosing class - #1746

Draft
StefanGraeber wants to merge 2 commits into
mainfrom
feature/1782_paramaterized_enclosing_class
Draft

StefanGraeber wants to merge 2 commits into
mainfrom
feature/1782_paramaterized_enclosing_class

Conversation

@StefanGraeber

Copy link
Copy Markdown
Contributor

No description provided.

…es before other completions

When parsing type annotations on types which anner INNER_TYPEs of other classes, it is required to know the enclosing class for a correct resolution.
Since type annotation parsing will happen as early as `completeTypeParameters` and inner classes can be referenced as bounds for type parameters of the outer class, all inner classes must know their onclosing class.
The same problem arises for any other usage of the inner class in the outer, e.g.
```
class Outer {
    private Outer.@TypeUseAnnotation Inner someField;
    class Inner {}
}
```
requires in `completeMembers` for type annotation resolution that the `Outer.Inner` knows its enclosing class.
Since it is not possible to reference classes declared inside a code unit, this resolution step may be incomplete when resolving type annotations.

The same list is iterated twice to avoid a behavior change.
The frist list changes the return value of `classes.getAllWithOuterClassesSortedBeforeInnerClasses()` to include more classes.
Calling that method twice causes the tests `creates_new_stub_type_variables_for_type_variables_of_enclosing_classes_that_are_out_of_context` in `ClassFileImporterGenericClassesTest` and `ClassFileImporterGenericMethodSignaturesTest` to fail

Signed-off-by: Stefan Gräber <stefan.graeber@tngtech.com>
…dType.getEnclosingType

If an inner class is enclosed by a class with generic arguments, it is possible to specify type arguments to the outer class like `Outer<T>.Inner`. In these cases, the Inner class must be represented by JavaParameterizedType even though it doesn't have a type parameter itself.

Signed-off-by: Stefan Gräber <stefan.graeber@tngtech.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant