eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Message "is not valid for an anonymous class with '<>'" may not be helpful

Open
#4,816 1 comment 0 reactions 1 assignee Claimed by @mpalat View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

Follow-up from https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4810#issuecomment-3837943457, where we saw this error message:
> `Type MyCallable inferred for MyCallable<>, is not valid for an anonymous class with '<>'`

**This error message doesn't make any sense**, independent of context: type `MyCallable` would be valid! But internally the type actually was something like `MyCallable`, where the second type argument is a CaptureBinding18. Its method shortReadableName() as used in the ProblemReporter hides the unspeakable type name, which however is essential for this error message.

The message should probably be rephrased to abstractly describe the offending type (smth like "an undenotable type variable"), in which case we might have to unfold the different reasons why a type is not denotable.

Starting point would be `ProblemReporter.anonymousDiamondWithNonDenotableTypeArguments()`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.