diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt index 0f21e253c9b..3bab8d4816e 100644 --- a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt @@ -5,17 +5,17 @@ public/*package*/ abstract class MethodTypeParameterBounds { public/*package*/ open fun f1(/*0*/ p0: T): kotlin.Unit public/*package*/ open fun f10(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3? public/*package*/ open fun ..@org.jetbrains.annotations.NotNull kotlin.Array)>!> f11(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3..@org.jetbrains.annotations.NotNull kotlin.Array)>? - public/*package*/ open fun !> f12(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I3 + public/*package*/ open fun !> f12(/*0*/ p0: _A!!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I3 public/*package*/ open fun ?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>!>!> f13(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!>?..@org.jetbrains.annotations.Nullable kotlin.Array!>!>!>?)>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>? public/*package*/ abstract fun ..@org.jetbrains.annotations.NotNull kotlin.Array)>!> f14(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>? public/*package*/ open fun !> f15(/*0*/ p0: _A!): kotlin.Unit where B : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I2<_A!> public/*package*/ open fun f2(/*0*/ p0: _A!, /*1*/ p1: B): kotlin.Unit public/*package*/ open fun f3(/*0*/ p0: _A!, /*1*/ p1: B): kotlin.Unit where B : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I1? - public/*package*/ open fun f4(/*0*/ p0: _A, /*1*/ p1: B!): kotlin.Unit + public/*package*/ open fun f4(/*0*/ p0: _A, /*1*/ p1: B!): kotlin.Unit public/*package*/ open fun f5(/*0*/ p0: _A!, /*1*/ p1: B): kotlin.Unit public/*package*/ open fun f6(): kotlin.Unit - public/*package*/ abstract fun f7(/*0*/ p0: _A!, /*1*/ p1: B): kotlin.Unit - public/*package*/ abstract fun f8(/*0*/ p0: _A, /*1*/ p1: B!, /*2*/ p2: C!, /*3*/ p3: D, /*4*/ p4: E!, /*5*/ p5: F!): kotlin.Unit + public/*package*/ abstract fun f7(/*0*/ p0: _A!, /*1*/ p1: B): kotlin.Unit + public/*package*/ abstract fun f8(/*0*/ p0: _A, /*1*/ p1: B!, /*2*/ p2: C!, /*3*/ p3: D, /*4*/ p4: E!, /*5*/ p5: F!): kotlin.Unit public/*package*/ open fun f9(/*0*/ p0: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2<@org.jetbrains.annotations.Nullable kotlin.Int?>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3? public/*package*/ interface I1 { diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt index c38c03b15b2..7cf68883d0e 100644 --- a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt @@ -5,17 +5,17 @@ public/*package*/ abstract class MethodTypeParameterBounds { public/*package*/ open fun f1(/*0*/ x: T): kotlin.Unit public/*package*/ open fun f10(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3? public/*package*/ open fun ..@org.jetbrains.annotations.NotNull kotlin.Array)>!> f11(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3..@org.jetbrains.annotations.NotNull kotlin.Array)>? - public/*package*/ open fun !> f12(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I3 + public/*package*/ open fun !> f12(/*0*/ x: _A!!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I3 public/*package*/ open fun ?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>!>!> f13(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!>?..@org.jetbrains.annotations.Nullable kotlin.Array!>!>!>?)>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>? public/*package*/ abstract fun ..@org.jetbrains.annotations.NotNull kotlin.Array)>!> f14(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3?..@org.jetbrains.annotations.Nullable kotlin.Array?)>!>? public/*package*/ open fun !> f15(/*0*/ x: _A!): kotlin.Unit where B : @org.jetbrains.annotations.NotNull test.MethodTypeParameterBounds.I2<_A!> public/*package*/ open fun f2(/*0*/ x: _A!, /*1*/ y: B): kotlin.Unit public/*package*/ open fun f3(/*0*/ x: _A!, /*1*/ y: B): kotlin.Unit where B : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I1? - public/*package*/ open fun f4(/*0*/ x: _A, /*1*/ y: B!): kotlin.Unit + public/*package*/ open fun f4(/*0*/ x: _A, /*1*/ y: B!): kotlin.Unit public/*package*/ open fun f5(/*0*/ x: _A!, /*1*/ y: B): kotlin.Unit public/*package*/ open fun f6(): kotlin.Unit - public/*package*/ abstract fun f7(/*0*/ x: _A!, /*1*/ y: B): kotlin.Unit - public/*package*/ abstract fun f8(/*0*/ x1: _A, /*1*/ x2: B!, /*2*/ x3: C!, /*3*/ x4: D, /*4*/ x5: E!, /*5*/ x6: F!): kotlin.Unit + public/*package*/ abstract fun f7(/*0*/ x: _A!, /*1*/ y: B): kotlin.Unit + public/*package*/ abstract fun f8(/*0*/ x1: _A, /*1*/ x2: B!, /*2*/ x3: C!, /*3*/ x4: D, /*4*/ x5: E!, /*5*/ x6: F!): kotlin.Unit public/*package*/ open fun f9(/*0*/ x: _A): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2<@org.jetbrains.annotations.Nullable kotlin.Int?>!, _A : @org.jetbrains.annotations.Nullable test.MethodTypeParameterBounds.I3? public/*package*/ interface I1 { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java index 58e642f4a13..473dae40c73 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java @@ -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); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt index 81c3701d2f9..24b64969f43 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt @@ -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)