Fix unchecked conversion not failed compilation#4961
Open
chrisrueger wants to merge 1 commit into
Open
Conversation
Detect when any explicit type argument is a raw type Adds regression test testGH4957 reproducing the Comparator.comparing + raw Comparable scenario (issue eclipse-jdt#4957) and asserting the expected warnings/errors. With this fix testGH4957 passes.
|
Hello, Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4957
What it does
How to test
org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_9.testGH4957()without the fix inorg.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(MethodBinding, TypeBinding[], Scope, InvocationSite)or just use e.g. Eclipse 2025-03 (or even 2026-06 (4.40) Build id: I20260319-1800 master) and paste the the following class:
Expected Result: Compilation should fail in Eclipse
Actual result: Compiliation succeeds.
But in javacc compilation fails.
With this PR compilation fails also in Eclipse.
But note: Eclipse seems to error with a different message than javac. Not sure this is a deeper problem. But at least it fails at the same place.
ECJ fails with:
while javac failed with:
Disclaimer:
I used AI to help me understand the issue and spec and find the places in the code. I have manually tested and debugged via latest JDT Dev environment via Oomph and ran my test in Eclipse.
This is my first step in the compiler space. Feel free to reject it or just use it as a base for a better fix if needed.
Author checklist
thoroughlytested my changes as good as I can