[FIR] Don't expand typealiases when checking for DeprecatedSinceKotlin
During serialization, this can lead to a cycle resulting in a Stack Overflow. #KT-58356 Fixed
This commit is contained in:
committed by
Space Team
parent
da884bd554
commit
c867a4b52f
+6
@@ -18429,6 +18429,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
|
|||||||
+6
@@ -18429,6 +18429,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
|
|||||||
+6
-8
@@ -103,7 +103,7 @@ fun FirAnnotationContainer.extractDeprecationInfoPerUseSite(
|
|||||||
): DeprecationAnnotationInfoPerUseSiteStorage {
|
): DeprecationAnnotationInfoPerUseSiteStorage {
|
||||||
val fromJava = this is FirDeclaration && this.isJavaOrEnhancement
|
val fromJava = this is FirDeclaration && this.isJavaOrEnhancement
|
||||||
return buildDeprecationAnnotationInfoPerUseSiteStorage {
|
return buildDeprecationAnnotationInfoPerUseSiteStorage {
|
||||||
add((customAnnotations ?: annotations).extractDeprecationAnnotationInfoPerUseSite(session, fromJava))
|
add((customAnnotations ?: annotations).extractDeprecationAnnotationInfoPerUseSite(fromJava))
|
||||||
if (this@extractDeprecationInfoPerUseSite is FirProperty) {
|
if (this@extractDeprecationInfoPerUseSite is FirProperty) {
|
||||||
add(
|
add(
|
||||||
getDeprecationsAnnotationInfoByUseSiteFromAccessors(
|
getDeprecationsAnnotationInfoByUseSiteFromAccessors(
|
||||||
@@ -158,7 +158,7 @@ fun List<FirAnnotation>.getDeprecationsProviderFromAnnotations(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
fromJava: Boolean
|
fromJava: Boolean
|
||||||
): DeprecationsProvider {
|
): DeprecationsProvider {
|
||||||
val deprecationAnnotationByUseSite = extractDeprecationAnnotationInfoPerUseSite(session, fromJava)
|
val deprecationAnnotationByUseSite = extractDeprecationAnnotationInfoPerUseSite(fromJava)
|
||||||
return deprecationAnnotationByUseSite.toDeprecationsProvider(session.firCachesFactory)
|
return deprecationAnnotationByUseSite.toDeprecationsProvider(session.firCachesFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,9 +199,7 @@ val deprecationAnnotationSimpleNames: Set<String> = setOf(
|
|||||||
StandardClassIds.Annotations.SinceKotlin.shortClassName.asString(),
|
StandardClassIds.Annotations.SinceKotlin.shortClassName.asString(),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(
|
private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(fromJava: Boolean): DeprecationAnnotationInfoPerUseSiteStorage {
|
||||||
session: FirSession, fromJava: Boolean
|
|
||||||
): DeprecationAnnotationInfoPerUseSiteStorage {
|
|
||||||
// NB: We can't expand typealiases (`toAnnotationClassId`), because it
|
// NB: We can't expand typealiases (`toAnnotationClassId`), because it
|
||||||
// requires `lookupTag.tySymbol()`, but we can have cycles in annotations.
|
// requires `lookupTag.tySymbol()`, but we can have cycles in annotations.
|
||||||
// See the commit message for an example.
|
// See the commit message for an example.
|
||||||
@@ -228,9 +226,9 @@ private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(
|
|||||||
} else {
|
} else {
|
||||||
val deprecationLevel = deprecated.getDeprecationLevel() ?: DeprecationLevelValue.WARNING
|
val deprecationLevel = deprecated.getDeprecationLevel() ?: DeprecationLevelValue.WARNING
|
||||||
val propagatesToOverride = !fromJavaAnnotation && !fromJava
|
val propagatesToOverride = !fromJavaAnnotation && !fromJava
|
||||||
val deprecatedSinceKotlin = getAnnotationsByClassId(
|
val deprecatedSinceKotlin = this@extractDeprecationAnnotationInfoPerUseSite.firstOrNull {
|
||||||
StandardClassIds.Annotations.DeprecatedSinceKotlin, session
|
it.unexpandedClassId == StandardClassIds.Annotations.DeprecatedSinceKotlin
|
||||||
).firstOrNull()
|
}
|
||||||
val message = deprecated.getStringArgument(ParameterNames.deprecatedMessage)
|
val message = deprecated.getStringArgument(ParameterNames.deprecatedMessage)
|
||||||
|
|
||||||
val deprecatedInfo =
|
val deprecatedInfo =
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// MODULE: sub
|
||||||
|
// FILE: sub.kt
|
||||||
|
package foo
|
||||||
|
|
||||||
|
class Base {
|
||||||
|
@RequiresOptIn
|
||||||
|
annotation class My
|
||||||
|
|
||||||
|
@My
|
||||||
|
@Deprecated("Yes")
|
||||||
|
fun test() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: dep(sub)
|
||||||
|
// FILE: box.kt
|
||||||
|
package some
|
||||||
|
|
||||||
|
import foo.Base
|
||||||
|
|
||||||
|
@OptIn(Base.My::class)
|
||||||
|
fun box() = Base().test()
|
||||||
+6
@@ -17631,6 +17631,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");
|
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
|
|||||||
+6
@@ -18429,6 +18429,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
|
|||||||
+6
@@ -18429,6 +18429,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
runTest("compiler/testData/codegen/box/fir/delegatedAndDataTogether.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
|
|||||||
+5
@@ -14643,6 +14643,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");
|
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("differentSinceKotlin.kt")
|
@TestMetadata("differentSinceKotlin.kt")
|
||||||
public void testDifferentSinceKotlin() throws Exception {
|
public void testDifferentSinceKotlin() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/differentSinceKotlin.kt");
|
runTest("compiler/testData/codegen/box/fir/differentSinceKotlin.kt");
|
||||||
|
|||||||
+6
@@ -13659,6 +13659,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -13761,6 +13761,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -13761,6 +13761,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -13761,6 +13761,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -14942,6 +14942,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -15292,6 +15292,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -14768,6 +14768,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -14943,6 +14943,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
|
|||||||
Generated
+5
@@ -12208,6 +12208,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("deserializedOptInDeprecated.kt")
|
||||||
|
public void testDeserializedOptInDeprecated() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/deserializedOptInDeprecated.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
@TestMetadata("falsePositiveBoundSmartcast.kt")
|
||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user