diff --git a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.kt b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.kt new file mode 100644 index 00000000000..929afa676e9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.kt @@ -0,0 +1,19 @@ +// FILE: A.java + +import java.util.*; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class A { + @NotNull + public T bar() { + } +} + +// FILE: k.kt + +fun test(a: A) { + a.bar()?.length + a.bar()?.length +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.txt b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.txt new file mode 100644 index 00000000000..a134dca259a --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.txt @@ -0,0 +1,11 @@ +package + +public fun test(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @org.jetbrains.annotations.NotNull() public open fun bar(): T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index ea2cbd03ea7..d5fc9838b04 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -12473,6 +12473,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("onTypeProjection.kt") + public void testOnTypeProjection() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/onTypeProjection.kt"); + doTest(fileName); + } + @TestMetadata("substitutionInSuperType.kt") public void testSubstitutionInSuperType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index 9615814a189..eae8d033232 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -522,7 +522,6 @@ public class TypeUtils { } @Nullable public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull KotlinType type) { - assert !(type instanceof CapturedType) : "Type should be non-captured " + type; if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) { return (TypeParameterDescriptor) type.getConstructor().getDeclarationDescriptor(); }