Revert "Make freshly substituted type variables def not nullable if they come from not null type parameter"
This reverts commit 41936a790b37bef45d7e7dad851856ea1750ef01.
This commit is contained in:
-6
@@ -925,12 +925,6 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated extends A
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
-6
@@ -925,12 +925,6 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTest
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
-6
@@ -925,12 +925,6 @@ public class FirOldFrontendForeignAnnotationsSourceJavaTestGenerated extends Abs
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
+1
-6
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
@@ -158,11 +157,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
|
||||
replacement = replacement.makeDefinitelyNotNullOrNotNull()
|
||||
}
|
||||
if (type is CustomTypeParameter) {
|
||||
replacement = type.substitutionResult(replacement).unwrap().run {
|
||||
if (type is NotNullTypeVariable && replacement.constructor is TypeVariableTypeConstructor) {
|
||||
makeDefinitelyNotNullOrNotNull()
|
||||
} else this
|
||||
}
|
||||
replacement = type.substitutionResult(replacement).unwrap()
|
||||
}
|
||||
|
||||
return replacement
|
||||
|
||||
+8
-8
@@ -23,24 +23,24 @@ public class Test {}
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
fun <T : Test> main(a1: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, a2: A<Test>, b1: B<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, b2: B<Test>, x: T): Unit {
|
||||
a1.foo(null)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
|
||||
a1.bar<T>(x)
|
||||
|
||||
a2.foo(null)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
|
||||
a2.bar<T>(x)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
b1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
|
||||
b1.bar<T>(x)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
|
||||
b2.bar<T>(x)
|
||||
}
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_RUNTIME
|
||||
|
||||
// FILE: Java.java
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Java<T extends @Nullable Object> {
|
||||
@NonNull T getFoo();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun usingMethod(java : Java<String?>) : String = java.getFoo()
|
||||
fun usingProperty(java : Java<String?>) : String = java.foo
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package
|
||||
|
||||
public fun usingMethod(/*0*/ java: Java<kotlin.String?>): kotlin.String
|
||||
public fun usingProperty(/*0*/ java: Java<kotlin.String?>): kotlin.String
|
||||
|
||||
public interface Java</*0*/ T> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@org.checkerframework.checker.nullness.qual.NonNull public abstract fun getFoo(): @org.checkerframework.checker.nullness.qual.NonNull T
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+4
-4
@@ -21,13 +21,13 @@ fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
|
||||
takeV(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>value<!>)
|
||||
takeVList(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>l<!>)
|
||||
|
||||
takeE(<!TYPE_MISMATCH!>value<!>)
|
||||
takeEList(<!TYPE_MISMATCH!>l<!>)
|
||||
takeE(<!TYPE_MISMATCH!>id(value)<!>)
|
||||
takeE(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>value<!>)
|
||||
takeEList(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>l<!>)
|
||||
takeE(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>id(value)<!>)
|
||||
|
||||
if (value != null) {
|
||||
takeV(value)
|
||||
takeE(<!DEBUG_INFO_SMARTCAST!>value<!>)
|
||||
takeE(value)
|
||||
takeE(id(value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.util.*
|
||||
fun use() {
|
||||
val x: String? = "x"
|
||||
Optional.of(x)
|
||||
// SUCCESS
|
||||
// UNSAFE_CALL_ERROR
|
||||
// ORIGINAL: fun <T : Any!> of(T): Optional<T> defined in java.util.Optional
|
||||
// SUBSTITUTED: fun <T : Any!> of(String): Optional<String> defined in java.util.Optional
|
||||
|
||||
|
||||
-6
@@ -925,12 +925,6 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
-6
@@ -925,12 +925,6 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
-6
@@ -925,12 +925,6 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48261.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48778.kt")
|
||||
public void testKt48778() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/misc/kt48778.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodWithTypeParameter.kt")
|
||||
public void testMethodWithTypeParameter() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user