KT-42933 inline class backing field can't be static

This commit is contained in:
Dmitry Petrov
2020-11-25 13:39:15 +03:00
parent f6abc5c3cf
commit e5dce9f994
10 changed files with 59 additions and 3 deletions
@@ -15155,6 +15155,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -69,11 +69,15 @@ fun getInlineClassUnderlyingType(irClass: IrClass): IrType {
fun getInlineClassBackingField(irClass: IrClass): IrField {
for (declaration in irClass.declarations) {
if (declaration is IrField)
if (declaration is IrField && !declaration.isStatic)
return declaration
if (declaration is IrProperty)
return declaration.backingField ?: continue
if (declaration is IrProperty) {
val backingField = declaration.backingField
if (backingField != null && !backingField.isStatic) {
return backingField
}
}
}
error("Inline class has no field: ${irClass.fqNameWhenAvailable}")
}
@@ -0,0 +1,12 @@
class Delegate {
operator fun getValue(t: Any?, p: Any): String = "OK"
}
inline class Kla1(val default: Int) {
fun getValue(): String {
val prop by Delegate()
return prop
}
}
fun box() = Kla1(1).getValue()
@@ -16555,6 +16555,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -16555,6 +16555,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -15155,6 +15155,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -13125,6 +13125,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -13125,6 +13125,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -13190,6 +13190,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testKt27070() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt");
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")
@@ -7440,6 +7440,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
public void testAllFilesPresentInPropertyDelegation() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("kt42933.kt")
public void testKt42933() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt42933.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter")