[FIR] Fix infinite loop in attribute substitution
#KT-65318 Fixed
This commit is contained in:
committed by
Space Team
parent
d047db850f
commit
9e72482f09
+6
@@ -838,6 +838,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated extend
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -896,6 +896,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingT
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -896,6 +896,12 @@ public class FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated extends
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
+11
-1
@@ -89,7 +89,17 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
|||||||
}
|
}
|
||||||
|
|
||||||
val substitutedType = newType ?: type.substituteRecursive()
|
val substitutedType = newType ?: type.substituteRecursive()
|
||||||
val substitutedAttributes = (substitutedType ?: type).attributes.transformTypesWith(this::substituteOrNull)
|
|
||||||
|
// Don't substitute attributes of flexible types because their bounds will be processed individually.
|
||||||
|
val substitutedAttributesOfUnsubstitutedType = runIf(type !is ConeFlexibleType) {
|
||||||
|
type.attributes.transformTypesWith(this::substituteOrNull)
|
||||||
|
}
|
||||||
|
val substitutedAttributes = substitutedAttributesOfUnsubstitutedType?.let {
|
||||||
|
// ConeAttribute.add is typically implemented to favor the RHS if both are not-null, so we use the substituted attributes as RHS.
|
||||||
|
// We can't do `(substitutedType ?: type).attributes.transformTypesWith(this::substituteOrNull)` because it could lead to an
|
||||||
|
// infinite loop in a situation like `{E -> Attr(E) Foo}` applied to `E`.
|
||||||
|
substitutedType?.attributes?.add(it) ?: it
|
||||||
|
}
|
||||||
|
|
||||||
return if (substitutedType != null || substitutedAttributes != null) {
|
return if (substitutedType != null || substitutedAttributes != null) {
|
||||||
var result = substitutedType ?: type
|
var result = substitutedType ?: type
|
||||||
|
|||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
|
// FILE: Super.java
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
|
||||||
|
@NullMarked
|
||||||
|
public abstract class Super<E extends Super<E>> implements Comparable<E> {
|
||||||
|
public final int compareTo(E o) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
open class E : Super<E>()
|
||||||
+6
@@ -838,6 +838,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -896,6 +896,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -896,6 +896,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
|||||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65318.kt")
|
||||||
|
public void testKt65318() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt65318.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||||
public void testNonPlatformTypeParameter() throws Exception {
|
public void testNonPlatformTypeParameter() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user