Skip to content

[GITHUB-9193] Resolve erroneous types in diamond-base new class expressions.#9212

Open
lahodaj wants to merge 1 commit intoapache:masterfrom
lahodaj:GITHUB-9193
Open

[GITHUB-9193] Resolve erroneous types in diamond-base new class expressions.#9212
lahodaj wants to merge 1 commit intoapache:masterfrom
lahodaj:GITHUB-9193

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Feb 17, 2026

Consider code like:

package test;
public class Test {
    public static class Test<T> {
        public Test(T value) { }
        public Test(String name, T value) { }
    }
    private static void test() {
        new Test<>/*CC here*/
    }
}

Invoking code completion at the marked place leads to an empty result. The issue is that when the new Test<> is attributed, it gets an erroneous type. I don't think there's currently a good argument to change the attribution, but the original type of the erroneous type is a usable type, so we can use that original type, and things should work.

The bug report says there's a difference between custom and JDK classes, but looking into that deeper, that's not the case. But there's a difference between classes that have a no-arg constructor, and those that only have constructors with arguments. The latter ones don't currently work, and would hopefully be fixed by this PR.

Closes #9193


^Add meaningful description above

Click to collapse/expand PR instructions

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.

If you're a first time contributor, see the Contributing guidelines for more information.

If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.

PR approval and merge checklist:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

@lahodaj lahodaj added this to the NB30 milestone Feb 17, 2026
@lahodaj lahodaj added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Feb 17, 2026
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

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

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constructor code completion doesn't work after diamond operator for non-JDK classes

2 participants