Import ConstructorResolver to handle null values

Previously, ConstructorResolver would reject any candidate if the
parameter is `null`. The reason for that is that null does not carry
any type and the matching algorithm would systematically fail for that
argument.

This commit adds an extra check, and several tests, to validate that
a null value is taken into account.

Closes gh-31495
This commit is contained in:
Stéphane Nicoll
2023-10-25 17:12:53 +02:00
parent fe7b6ddf88
commit 4977ef9cea
2 changed files with 48 additions and 1 deletions

View File

@@ -1200,7 +1200,8 @@ class ConstructorResolver {
}
private Predicate<ResolvableType> isAssignable(ResolvableType valueType) {
return parameterType -> parameterType.isAssignableFrom(valueType);
return parameterType -> (valueType == ResolvableType.NONE
|| parameterType.isAssignableFrom(valueType));
}
private ResolvableType extractElementType(ResolvableType parameterType) {