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

False positive error with a <?> wildcard type assigned to var #6675

Open
alexvas opened this issue Jun 24, 2024 · 0 comments
Open

False positive error with a <?> wildcard type assigned to var #6675

alexvas opened this issue Jun 24, 2024 · 0 comments

Comments

@alexvas
Copy link

alexvas commented Jun 24, 2024

Commands

java -version -Aversion -AprintGitProperties -verbose -AprintVerboseGenerics
java -jar "$CHECKER_FRAMEWORK/checker/dist/checker.jar" -processor nullness Foo.java

Inputs

A single input named Foo.java:

interface Foo<T>{
}

record Bar(Foo<?> foo) {

	void bazz() {
		var clazz = foo.getClass();
	}
}

Outputs

openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-122.04.1)
OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-122.04.1, mixed mode, sharing)
error: [type.argument] incompatible type argument for type parameter T of Class.
  found   : capture#01[ extends @UnknownKeyFor Foo</*RAW TYPE ARGUMENT:*/ ?[ extends @UnknownKeyFor Object super @UnknownKeyFor Void]> super @KeyForBottom Void]
  required: [extends @UnknownKeyFor Object super @UnknownKeyFor NullType]
1 error

Expectation

No error, like in

interface Foo<T>{
}

record Bar(Foo<?> foo) {

	void bazz() {
		Class<?> clazz = foo.getClass();
	}
}

case.

@alexvas alexvas changed the title crash with a <?> wildcard crash with a <?> wildcard type assigned to var Jun 24, 2024
@smillst smillst changed the title crash with a <?> wildcard type assigned to var False positive error with a <?> wildcard type assigned to var Jun 25, 2024
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

No branches or pull requests

1 participant