FE: do not wrap types with enhancements if they're the same
This commit is contained in:
compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.fir.kt
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// JSPECIFY_STATE: strict
|
||||||
|
// !LANGUAGE: +TypeEnhancementImprovementsInStrictMode
|
||||||
|
// FILE: J1.java
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface J1<T> {
|
||||||
|
@Nullable
|
||||||
|
public static <T> T foo(J1<T> x) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: J2.java
|
||||||
|
import org.jspecify.nullness.Nullable;
|
||||||
|
|
||||||
|
public interface J2<V extends @Nullable Object> extends J1<V> { }
|
||||||
|
|
||||||
|
// FILE: kotlin.kt
|
||||||
|
private fun J2<*>.bar() = J1.foo(this)
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
private fun J2<*>.bar(): @org.jspecify.nullness.Nullable kotlin.Any?
|
||||||
|
|
||||||
|
public interface J1</*0*/ T : kotlin.Any!> {
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
@org.jetbrains.annotations.Nullable public open fun </*0*/ T : kotlin.Any!> foo(/*0*/ x: J1<T!>!): @org.jetbrains.annotations.Nullable T?
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface J2</*0*/ V> : J1<V> {
|
||||||
|
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
|
||||||
|
}
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// JSPECIFY_STATE: strict
|
||||||
|
// !LANGUAGE: +TypeEnhancementImprovementsInStrictMode
|
||||||
|
// FILE: J1.java
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface J1<T> {
|
||||||
|
@Nullable
|
||||||
|
public static <T> T foo(J1<T> x) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: J2.java
|
||||||
|
import org.jspecify.nullness.Nullable;
|
||||||
|
|
||||||
|
public interface J2<V extends @Nullable Object> extends J1<V> { }
|
||||||
|
|
||||||
|
// FILE: kotlin.kt
|
||||||
|
private fun J2<*>.bar() = J1.foo(this)
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
private fun J2<*>.bar(): @org.jspecify.nullness.Nullable kotlin.Any?
|
||||||
|
|
||||||
|
public interface J1</*0*/ T : kotlin.Any!> {
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
@org.jetbrains.annotations.Nullable public open fun </*0*/ T : kotlin.Any!> foo(/*0*/ x: J1<T!>!): @org.jetbrains.annotations.Nullable T?
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface J2</*0*/ V> : J1<V> {
|
||||||
|
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
|
||||||
|
}
|
||||||
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// JSPECIFY_STATE: warn
|
||||||
|
// FILE: J1.java
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface J1<T> {
|
||||||
|
@Nullable
|
||||||
|
public static <T> T foo(J1<T> x) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: J2.java
|
||||||
|
import org.jspecify.nullness.Nullable;
|
||||||
|
|
||||||
|
public interface J2<V extends @Nullable Object> extends J1<V> { }
|
||||||
|
|
||||||
|
// FILE: kotlin.kt
|
||||||
|
private fun J2<*>.bar() = J1.foo(this)
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
private fun J2<*>.bar(): @org.jspecify.nullness.Nullable kotlin.Any?
|
||||||
|
|
||||||
|
public interface J1</*0*/ T : kotlin.Any!> {
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
@org.jetbrains.annotations.Nullable public open fun </*0*/ T : kotlin.Any!> foo(/*0*/ x: J1<T!>!): @org.jetbrains.annotations.Nullable T?
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface J2</*0*/ V : @org.jspecify.nullness.Nullable kotlin.Any!> : J1<V!> {
|
||||||
|
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
|
||||||
|
}
|
||||||
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// JSPECIFY_STATE: warn
|
||||||
|
// FILE: J1.java
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface J1<T> {
|
||||||
|
@Nullable
|
||||||
|
public static <T> T foo(J1<T> x) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: J2.java
|
||||||
|
import org.jspecify.nullness.Nullable;
|
||||||
|
|
||||||
|
public interface J2<V extends @Nullable Object> extends J1<V> { }
|
||||||
|
|
||||||
|
// FILE: kotlin.kt
|
||||||
|
private fun J2<*>.bar() = J1.foo(this)
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
private fun J2<*>.bar(): @org.jspecify.nullness.Nullable kotlin.Any?
|
||||||
|
|
||||||
|
public interface J1</*0*/ T : kotlin.Any!> {
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
@org.jetbrains.annotations.Nullable public open fun </*0*/ T : kotlin.Any!> foo(/*0*/ x: J1<T!>!): @org.jetbrains.annotations.Nullable T?
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface J2</*0*/ V : @org.jspecify.nullness.Nullable kotlin.Any!> : J1<V!> {
|
||||||
|
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
|
||||||
|
}
|
||||||
+24
@@ -636,6 +636,18 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
@@ -784,6 +796,18 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
|
|||||||
+24
@@ -636,6 +636,18 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
@@ -784,6 +796,18 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
|
|||||||
+24
@@ -636,6 +636,18 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
@@ -784,6 +796,18 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.kt")
|
||||||
|
public void testCaptured() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("Captured.fir.kt")
|
||||||
|
public void testCaptured_fir() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.fir.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Defaults.kt")
|
@TestMetadata("Defaults.kt")
|
||||||
public void testDefaults() throws Exception {
|
public void testDefaults() throws Exception {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ fun UnwrappedType.wrapEnhancement(enhancement: KotlinType?): UnwrappedType {
|
|||||||
if (this is TypeWithEnhancement) {
|
if (this is TypeWithEnhancement) {
|
||||||
return origin.wrapEnhancement(enhancement)
|
return origin.wrapEnhancement(enhancement)
|
||||||
}
|
}
|
||||||
if (enhancement == null) {
|
if (enhancement == null || enhancement == this) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
return when (this) {
|
return when (this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user