The GitHub Actions job "Running Copilot Code Review" on commons-lang.git/master 
has failed.
Run started by GitHub user Copilot (triggered by Copilot).

Head commit for run:
99618eb840cf18d31413c4fdfad2e4503322fd70 / XenoAmess <[email protected]>
Fix TypeUtils.isAssignable rejecting Class<X> to Class<?> assignments (#1820)

* Fix TypeUtils.isAssignable() rejecting Class<X> to Class<?> assignments 
(#1548 follow-up)

The Class-specialized check added for #1548 (LANG-1749) requires the type
argument of java.lang.Class to match exactly, but it did not account for
wildcard type arguments on the target side. As a result, assignments that
the Java compiler accepts are rejected:

  Class<Integer> -> Class<?>                javac: OK, TypeUtils: false
  Class<String>  -> Class<? extends Object> javac: OK, TypeUtils: false
  Class<List<String>> -> Class<? extends Collection<?>>: false

When the target type argument is a wildcard, check that the subject type
argument is contained by the wildcard instead of demanding equality. A raw
generic class still does not satisfy a parameterized bound, since Class is
invariant and javac does not apply unchecked conversion to its type
argument, keeping the #1548 cases (e.g. Class<TestImpl> to
Class<? extends TestIF<?>>) rejected.

* Handle source wildcards and type variables in Class assignability

Reuse wildcard containment checks to support upper and lower bounds, and 
preserve source type variables declared outside java.lang.Class. Limit the raw 
generic argument guard to parameterized upper bounds so legal lower-bound 
assignments remain accepted.

Add regression tests for these cases. All five new test methods fail with the 
original upstream Class check; the default mvn build passes with the fix.

* [LANG-1749] Reject unchecked wildcard bounds in Class assignability

Propagate a no-unchecked-conversion mode through wildcard bounds, generic
array components, and parameterized supertypes. Reject raw ancestors and
preserve external type variables while resolving parameterized parents.
This applies the same subtype checks to upper and lower wildcard bounds.

Return false when unrelated source type variables have no matching bound
instead of throwing IllegalStateException.

Add 39 compiler-checked Class wildcard assignment cases and a direct type
variable regression test. The original PR implementation produces 16
assertion failures and 6 errors with the new tests.

Report URL: https://github.com/apache/commons-lang/actions/runs/38797370828

With regards,
GitHub Actions via GitBox

Reply via email to