Added tests for KT-29833

This commit is contained in:
Dmitry Petrov
2019-02-15 14:29:27 +03:00
parent 4c3d0cd9d7
commit 08de82db85
8 changed files with 107 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// TARGET_BACKEND: JVM
// FILE: Definitions.kt
import interop.*
object Definitions {
const val KT_CONSTANT = Interface.CONSTANT
val ktValue = Interface.CONSTANT
}
fun box(): String =
Definitions.ktValue
// FILE: interop/Interface.java
package interop;
public class Interface {
public static final String CONSTANT = "OK";
}
+17
View File
@@ -0,0 +1,17 @@
// FILE: Definitions.kt
// IR_FILE: kt29833.txt
package interop
object Definitions {
const val KT_CONSTANT = Interface.CONSTANT
val ktValue = Interface.CONSTANT
}
// FILE: interop/Interface.java
package interop;
class Interface {
public static final String CONSTANT = "constant";
public CharSequence chars;
}
+42
View File
@@ -0,0 +1,42 @@
FILE fqName:interop fileName:/Definitions.kt
CLASS OBJECT name:Definitions modality:FINAL visibility:public flags: superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:interop.Definitions flags:
CONSTRUCTOR visibility:private <> () returnType:interop.Definitions flags:primary
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
INSTANCE_INITIALIZER_CALL classDescriptor='Definitions'
PROPERTY name:KT_CONSTANT visibility:public modality:FINAL flags:const,val
FIELD PROPERTY_BACKING_FIELD name:KT_CONSTANT type:kotlin.String visibility:public flags:final
EXPRESSION_BODY
CONST String type=kotlin.String value="constant"
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-KT_CONSTANT> visibility:public modality:FINAL <> ($this:interop.Definitions) returnType:kotlin.String flags:
correspondingProperty: PROPERTY name:KT_CONSTANT visibility:public modality:FINAL flags:const,val
$this: VALUE_PARAMETER name:<this> type:interop.Definitions flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-KT_CONSTANT>(): String'
GET_FIELD 'KT_CONSTANT: String' type=kotlin.String origin=null
receiver: GET_VAR 'this@Definitions: Definitions' type=interop.Definitions origin=null
PROPERTY name:ktValue visibility:public modality:FINAL flags:val
FIELD PROPERTY_BACKING_FIELD name:ktValue type:kotlin.String visibility:public flags:final
EXPRESSION_BODY
GET_FIELD 'CONSTANT: String' type=kotlin.String origin=GET_PROPERTY
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-ktValue> visibility:public modality:FINAL <> ($this:interop.Definitions) returnType:kotlin.String flags:
correspondingProperty: PROPERTY name:ktValue visibility:public modality:FINAL flags:val
$this: VALUE_PARAMETER name:<this> type:interop.Definitions flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-ktValue>(): String'
GET_FIELD 'ktValue: String' type=kotlin.String origin=null
receiver: GET_VAR 'this@Definitions: Definitions' type=interop.Definitions origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean flags:
overridden:
FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean flags:
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int flags:
overridden:
FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int flags:
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String flags:
overridden:
FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String flags:
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
@@ -236,6 +236,15 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
private fun IrSymbol.checkBinding(kind: String, irElement: IrElement) {
if (!isBound) {
error("${javaClass.simpleName} $descriptor is unbound @$kind ${irElement.render()}")
} else {
val irDeclaration = owner as? IrDeclaration
if (irDeclaration != null) {
try {
irDeclaration.parent
} catch (e: Throwable) {
error("Referenced declaration has no parent: ${irDeclaration.render()}")
}
}
}
val otherSymbol = symbolForDeclaration.getOrPut(owner) { this }
@@ -13432,6 +13432,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
}
@TestMetadata("kt29833.kt")
public void testKt29833() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
}
@TestMetadata("objectClass.kt")
public void testObjectClass() throws Exception {
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
@@ -13432,6 +13432,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
}
@TestMetadata("kt29833.kt")
public void testKt29833() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
}
@TestMetadata("objectClass.kt")
public void testObjectClass() throws Exception {
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
@@ -13437,6 +13437,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
}
@TestMetadata("kt29833.kt")
public void testKt29833() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
}
@TestMetadata("objectClass.kt")
public void testObjectClass() throws Exception {
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
@@ -274,6 +274,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/declarations/kt27005.kt");
}
@TestMetadata("kt29833.kt")
public void testKt29833() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt29833.kt");
}
@TestMetadata("localClassWithOverrides.kt")
public void testLocalClassWithOverrides() throws Exception {
runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt");