You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use generic typed objects (such as List<String>) as optional parameters, it is not possible to automatically infer the generic type. Instead, the type must be explicitly specified, otherwise, a type mismatch error occurs.
publicclassTest {
//Incompatible types: 'List<Object>' cannot be converted to 'List<String>'publicvoidtest1(List<String> string = List.of()){ }
//Incompatible types: 'ArrayList<Object>' cannot be converted to 'List<String>'publicvoidtest2(List<String> string = newArrayList<>()){ }
// OKpublicvoidtest3(List<String> string = newArrayList<String>()){ }
}
Is there a technical limitation that prevents generic types from being automatically inferred for optional parameters?
The text was updated successfully, but these errors were encountered:
EotT123
pushed a commit
to EotT123/manifold-test
that referenced
this issue
Apr 19, 2025
Uh oh!
There was an error while loading. Please reload this page.
When trying to use generic typed objects (such as
List<String>
) as optional parameters, it is not possible to automatically infer the generic type. Instead, the type must be explicitly specified, otherwise, a type mismatch error occurs.Is there a technical limitation that prevents generic types from being automatically inferred for optional parameters?
The text was updated successfully, but these errors were encountered: