FIR: Fix wrong ACCIDENTAL_OVERRIDE on fake override property with JvmName
This commit is contained in:
committed by
teamcityserver
parent
6f55d23bab
commit
a7859e0332
+17
-10
@@ -504,7 +504,7 @@ class Fir2IrDeclarationStorage(
|
||||
containerSource = simpleFunction?.containerSource,
|
||||
).apply {
|
||||
metadata = FirMetadataSource.Function(function)
|
||||
convertAnnotationsFromLibrary(function)
|
||||
convertAnnotationsForNonDeclaredMembers(function, origin)
|
||||
enterScope(this)
|
||||
bindAndDeclareParameters(
|
||||
function, irParent,
|
||||
@@ -626,6 +626,7 @@ class Fir2IrDeclarationStorage(
|
||||
endOffset: Int,
|
||||
isLocal: Boolean = false,
|
||||
containingClass: ConeClassLikeLookupTag? = null,
|
||||
propertyAccessorForAnnotations: FirPropertyAccessor? = propertyAccessor,
|
||||
): IrSimpleFunction = convertCatching(propertyAccessor ?: property) {
|
||||
val prefix = if (isSetter) "set" else "get"
|
||||
val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter, containingClass)
|
||||
@@ -654,7 +655,11 @@ class Fir2IrDeclarationStorage(
|
||||
if (propertyAccessor != null) {
|
||||
metadata = FirMetadataSource.Function(propertyAccessor)
|
||||
// Note that deserialized annotations are stored in the accessor, not the property.
|
||||
convertAnnotationsFromLibrary(propertyAccessor)
|
||||
convertAnnotationsForNonDeclaredMembers(propertyAccessor, origin)
|
||||
}
|
||||
|
||||
if (propertyAccessorForAnnotations != null) {
|
||||
convertAnnotationsForNonDeclaredMembers(propertyAccessorForAnnotations, origin)
|
||||
}
|
||||
with(classifierStorage) {
|
||||
setTypeParameters(
|
||||
@@ -710,7 +715,7 @@ class Fir2IrDeclarationStorage(
|
||||
it.correspondingPropertySymbol = this@createBackingField.symbol
|
||||
}.apply {
|
||||
metadata = FirMetadataSource.Property(property)
|
||||
convertAnnotationsFromLibrary(property)
|
||||
convertAnnotationsForNonDeclaredMembers(property, origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -812,7 +817,7 @@ class Fir2IrDeclarationStorage(
|
||||
containerSource = property.containerSource,
|
||||
).apply {
|
||||
metadata = FirMetadataSource.Property(property)
|
||||
convertAnnotationsFromLibrary(property)
|
||||
convertAnnotationsForNonDeclaredMembers(property, origin)
|
||||
enterScope(this)
|
||||
if (irParent != null) {
|
||||
parent = irParent
|
||||
@@ -860,7 +865,8 @@ class Fir2IrDeclarationStorage(
|
||||
getter is FirDefaultPropertyGetter -> IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR
|
||||
else -> origin
|
||||
},
|
||||
startOffset, endOffset, isLocal, containingClass
|
||||
startOffset, endOffset, isLocal, containingClass,
|
||||
property.unwrapFakeOverrides().getter,
|
||||
)
|
||||
if (property.isVar) {
|
||||
this.setter = createIrPropertyAccessor(
|
||||
@@ -870,7 +876,8 @@ class Fir2IrDeclarationStorage(
|
||||
setter is FirDefaultPropertySetter -> IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR
|
||||
else -> origin
|
||||
},
|
||||
startOffset, endOffset, isLocal, containingClass
|
||||
startOffset, endOffset, isLocal, containingClass,
|
||||
property.unwrapFakeOverrides().setter,
|
||||
)
|
||||
}
|
||||
leaveScope(this)
|
||||
@@ -1403,10 +1410,10 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrMutableAnnotationContainer.convertAnnotationsFromLibrary(firAnnotationContainer: FirAnnotationContainer) {
|
||||
if ((firAnnotationContainer as? FirDeclaration)?.isFromLibrary == true ||
|
||||
(firAnnotationContainer is FirCallableDeclaration && firAnnotationContainer.isSubstitutionOrIntersectionOverride)
|
||||
) {
|
||||
private fun IrMutableAnnotationContainer.convertAnnotationsForNonDeclaredMembers(
|
||||
firAnnotationContainer: FirAnnotationContainer, origin: IrDeclarationOrigin,
|
||||
) {
|
||||
if ((firAnnotationContainer as? FirDeclaration)?.isFromLibrary == true || origin == IrDeclarationOrigin.FAKE_OVERRIDE) {
|
||||
annotationGenerator.generate(this, firAnnotationContainer)
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -25804,6 +25804,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeJvmNameInJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideOfProperty.kt")
|
||||
public void testFakeOverrideOfProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeOverrideOfProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionName.kt")
|
||||
public void testFunctionName() throws Exception {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class Base {
|
||||
protected abstract fun getChart(context: CharSequence): String
|
||||
|
||||
@get:JvmName("getChartHelper")
|
||||
public val CharSequence.chart get() = getChart(this)
|
||||
}
|
||||
|
||||
abstract class Derived1 : Base()
|
||||
|
||||
class Derived2 : Derived1() {
|
||||
override fun getChart(context: CharSequence): String {
|
||||
return context.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return with(Derived2()) {
|
||||
"OK".chart
|
||||
}
|
||||
}
|
||||
+6
@@ -25642,6 +25642,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeJvmNameInJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideOfProperty.kt")
|
||||
public void testFakeOverrideOfProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeOverrideOfProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionName.kt")
|
||||
public void testFunctionName() throws Exception {
|
||||
|
||||
+6
@@ -25804,6 +25804,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeJvmNameInJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideOfProperty.kt")
|
||||
public void testFakeOverrideOfProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeOverrideOfProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionName.kt")
|
||||
public void testFunctionName() throws Exception {
|
||||
|
||||
+5
@@ -21628,6 +21628,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeJvmNameInJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fakeOverrideOfProperty.kt")
|
||||
public void testFakeOverrideOfProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeOverrideOfProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionName.kt")
|
||||
public void testFunctionName() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/functionName.kt");
|
||||
|
||||
+6
@@ -26115,6 +26115,12 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeJvmNameInJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideOfProperty.kt")
|
||||
public void testFakeOverrideOfProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmName/fakeOverrideOfProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionName.kt")
|
||||
public void testFunctionName() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user