New J2K: make function parameters which is used as spread value argument to be not null
This commit is contained in:
+6
-1
@@ -240,7 +240,12 @@ internal class ConstraintsCollector(
|
||||
|
||||
|
||||
for (argumentIndex in callExpression.valueArguments.indices) {
|
||||
val argument = callExpression.valueArguments[argumentIndex].getArgumentExpression() ?: continue
|
||||
val valueArgument = callExpression.valueArguments[argumentIndex]
|
||||
val argument = valueArgument.getArgumentExpression() ?: continue
|
||||
|
||||
if (valueArgument.isSpread) {
|
||||
argument.addEqualsNullabilityConstraint(Nullability.NOT_NULL, ConstraintCameFrom.USED_AS_RECEIVER)
|
||||
}
|
||||
|
||||
argument.addSubtypeNullabilityConstraint(
|
||||
parameterBoundTypeIndex(argumentIndex) ?: continue,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import java.lang.reflect.Constructor
|
||||
|
||||
fun <T> foo(constructor: Constructor<T>, args: Array<Any>) {
|
||||
constructor.newInstance(*args)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import java.lang.reflect.Constructor
|
||||
|
||||
fun <T> foo(constructor: Constructor<T?>, args: Array<Any?>) {
|
||||
constructor.newInstance(*args)
|
||||
}
|
||||
@@ -64,6 +64,11 @@ public class NullabilityAnalysisTestGenerated extends AbstractNullabilityAnalysi
|
||||
runTest("nj2k/testData/nullabilityAnalysis/smartCast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("spreadExpression.kt")
|
||||
public void testSpreadExpression() throws Exception {
|
||||
runTest("nj2k/testData/nullabilityAnalysis/spreadExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("superMethod.kt")
|
||||
public void testSuperMethod() throws Exception {
|
||||
runTest("nj2k/testData/nullabilityAnalysis/superMethod.kt");
|
||||
|
||||
Reference in New Issue
Block a user