JVM IR: fix class kind of created java.lang.Deprecated symbol

If it isn't ANNOTATION_CLASS, the newly added code in
`FunctionCodegen.isDeprecatedHidden` (0e91d3fcb0) ends up transforming
IR annotation constructor calls to annotation descriptors, and an
assertion fails in `IrBasedDeclarationDescriptor.toAnnotationDescriptor`
which checks that the class has kind ANNOTATION_CLASS.

Specifically, this failed in the JVM IR bootstrap on
`CallResolutionInterceptorExtension.interceptCandidates` from module
'frontend'.
This commit is contained in:
Alexander Udalov
2020-11-10 21:28:56 +01:00
parent c1b73f5fee
commit 116606ecd2
7 changed files with 64 additions and 1 deletions
@@ -16759,6 +16759,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/defaultArgsViaAnonymousObject.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("funInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/funInterface.kt");
@@ -16890,6 +16895,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedAnnotation.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("inheritedFunctionWithDefaultParameters.kt")
public void testInheritedFunctionWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedFunctionWithDefaultParameters.kt");
@@ -209,7 +209,7 @@ class JvmSymbols(
}
private val javaLangDeprecatedWithDeprecatedFlag: IrClassSymbol =
createClass(FqName("java.lang.Deprecated")) { klass ->
createClass(FqName("java.lang.Deprecated"), classKind = ClassKind.ANNOTATION_CLASS) { klass ->
klass.addConstructor { isPrimary = true }
}
@@ -0,0 +1,11 @@
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface I {
@Deprecated("message")
fun result() = "OK"
}
fun box(): String = object : I {}.result()
@@ -0,0 +1,12 @@
// !JVM_DEFAULT_MODE: compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface I {
@Deprecated("message")
@JvmDefault
fun result() = "OK"
}
fun box(): String = object : I {}.result()
@@ -18159,6 +18159,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/defaultArgsViaAnonymousObject.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("funInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/funInterface.kt");
@@ -18290,6 +18295,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedAnnotation.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("inheritedFunctionWithDefaultParameters.kt")
public void testInheritedFunctionWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedFunctionWithDefaultParameters.kt");
@@ -18159,6 +18159,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/defaultArgsViaAnonymousObject.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("funInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/funInterface.kt");
@@ -18290,6 +18295,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedAnnotation.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("inheritedFunctionWithDefaultParameters.kt")
public void testInheritedFunctionWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedFunctionWithDefaultParameters.kt");
@@ -16759,6 +16759,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/defaultArgsViaAnonymousObject.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("funInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/funInterface.kt");
@@ -16890,6 +16895,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedAnnotation.kt");
}
@TestMetadata("deprecatedDefaultMethod.kt")
public void testDeprecatedDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/deprecatedDefaultMethod.kt");
}
@TestMetadata("inheritedFunctionWithDefaultParameters.kt")
public void testInheritedFunctionWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedFunctionWithDefaultParameters.kt");