Skip to content

Conversation

@tanishiking
Copy link
Member

@tanishiking tanishiking commented Nov 11, 2025

Fixes #24074

When Java methods use covariant array return types (e.g., B[] getData() overriding A[] getData()), the compiler failed to recognize them as valid overrides because Scala sees those array invaliant.

This PR adds special handling in TypeComparer to treat Java arrays as covariant during override checking for AppliedType(Array, ...) where Array.is(JavaDefined).

Not very confident this is the clear solution for the issue, and some other tests would fail.

&& args1.length == 1 =>
// Check if element types are Java-defined to detect Java arrays
val elem1Sym = args1.head.typeSymbol
val elem2Sym = arg2.typeSymbol
Copy link
Member Author

@tanishiking tanishiking Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it doesn't work if the elemnt type is defined in Scala :/
We need to somehow check AppliedType(ArrayClass, args)s are JavaArray or not 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant