Fix ISE when copying a function with @NotNull bounded type parameters
For example in the case:
<_A extends @NotNull B, B> void f4(_A x, B y) { }
ISE had happened because while substituting the function
we've been creating copies of old type parameters and when initializing
bounds for one of them bounds for other may not be initialized yet
at the same time bounds were necessary for makesSenseToBeDefinitelyNotNull
This commit is contained in:
committed by
Mikhael Bogdanov
parent
0c419eac1a
commit
699d53e7f9
+4
@@ -132,6 +132,10 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public void addUpperBound(@NotNull KotlinType bound) {
|
||||
checkUninitialized();
|
||||
doAddUpperBound(bound);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
@@ -127,6 +128,10 @@ class DefinitelyNotNullType private constructor(
|
||||
|
||||
if (type is StubTypeForBuilderInference) return TypeUtils.isNullableType(type)
|
||||
|
||||
if ((type.constructor.declarationDescriptor as? TypeParameterDescriptorImpl)?.isInitialized == false) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Replacing `useCorrectedNullabilityForFlexibleTypeParameters` with true for all call-sites seems to be correct
|
||||
// But it seems that it should be a new feature: KT-28785 would be automatically fixed then
|
||||
// (see the tests org.jetbrains.kotlin.spec.checkers.DiagnosticsTestSpecGenerated.NotLinked.Dfa.Pos.test12/13)
|
||||
|
||||
Reference in New Issue
Block a user