Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomprehensible warning when using recursive generics in IntelliJ IDEA #4902

Closed
Lignium opened this issue Aug 26, 2021 · 4 comments
Closed

Comments

@Lignium
Copy link

Lignium commented Aug 26, 2021

When using recursive generics, for example, creating a self-reference, an incomprehensible warning is raised. When using simple non-recursive generics, there is no warning. Perhaps I do not understand something? Maybe this is an IDE bug?

Experiment.java

package org.lignium.experiment;

public final class Experiment {
    private static abstract class Region<R extends Region<R>> {
        public abstract R self();
    }
    private static final class CuboidRegion extends Region<CuboidRegion> {
        @Override
        public CuboidRegion self() {
            return this;
        }
    }
    public static void main(String[] arguments) {
        // Warning at wildcard: Non-null type argument is expected
        Region<?> region = new CuboidRegion();
    }
}

package-info.java

@DefaultQualifier(NonNull.class)
package org.lignium.experiment;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@smillst
Copy link
Member

smillst commented Sep 8, 2021

I can't reproduce any error for this example.

javacheck -processor nullness Experiment.java package-info.java

@Lignium
Copy link
Author

Lignium commented Sep 9, 2021

Is it an IntelliJ IDEA bug?

@smillst
Copy link
Member

smillst commented Sep 9, 2021

The warning you mention, Non-null type argument is expected, is produced by IntelliJ IDEA not the Nullness Checker. Since I can't reproduce the error, I can't say if it's an IntelliJ IDEA bug.

@mernst
Copy link
Member

mernst commented Sep 9, 2021

Since the error is produced by IntelliJ IDEA, I'm closing this issue.

@mernst mernst closed this as completed Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants