Skip to content

#1382 completeClassHierarchy and completeEnclosingClass for all classes before other completions - #1744

Open
StefanGraeber wants to merge 1 commit into
mainfrom
feature/1382_eager_enclosing_class_resolution
Open

StefanGraeber wants to merge 1 commit into
mainfrom
feature/1382_eager_enclosing_class_resolution

Conversation

@StefanGraeber

@StefanGraeber StefanGraeber commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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

…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>
@schulzjo-tng schulzjo-tng changed the title #1382 completeClassHierarchy and completeEnclosingClass for all class… #1382 completeClassHierarchy and completeEnclosingClass for all classes before other completions Oct 9, 2026

@schulzjo-tng schulzjo-tng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the typos in the PR description before merging, since those can go into the merge commit. Rest looks good 👍

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.

2 participants