Rewrite ir interpreter's dump tests to box
Box tests will check the correctness of interpreter, meantime by dumped ir we can understand that expression was folded.
This commit is contained in:
@@ -61,7 +61,7 @@ class FirModuleDescriptor(val session: FirSession) : ModuleDescriptor {
|
||||
}
|
||||
|
||||
override fun getName(): Name {
|
||||
return Name.identifier("module for FIR session")
|
||||
return FIR_MODULE_NAME
|
||||
}
|
||||
|
||||
override val stableName: Name?
|
||||
@@ -74,4 +74,7 @@ class FirModuleDescriptor(val session: FirSession) : ModuleDescriptor {
|
||||
override val annotations: Annotations
|
||||
get() = Annotations.EMPTY
|
||||
|
||||
companion object {
|
||||
val FIR_MODULE_NAME = Name.identifier("module for FIR session")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/ir/loweredIr")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DumpLoweredIrTestGenerated extends AbstractDumpLoweredIrTest {
|
||||
public class LoweredIrInterpreterTestGenerated extends AbstractLoweredIrInterpreterTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInLoweredIr() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/loweredIr"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
@@ -5,4 +5,10 @@ const val complexTrimIndent =
|
||||
ABC
|
||||
123
|
||||
456
|
||||
""".trimIndent()
|
||||
""".trimIndent()
|
||||
|
||||
fun box(): String {
|
||||
if (trimIndent != "123") return "Fail 1"
|
||||
if (complexTrimIndent != "ABC\n123\n456") return "Fail 2"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/constTrimIndent.kt
|
||||
PROPERTY name:trimIndent visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:trimIndent type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="123"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-trimIndent> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:trimIndent visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-trimIndent> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:trimIndent type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:complexTrimIndent visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:complexTrimIndent type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="ABC\n123\n456"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-complexTrimIndent> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:complexTrimIndent visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-complexTrimIndent> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexTrimIndent type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
@@ -10,3 +10,10 @@ const val withoutMargin = """
|
||||
#foo
|
||||
#bar
|
||||
""".trimMargin("#")
|
||||
|
||||
fun box(): String {
|
||||
if (trimMargin != "123") return "Fail 1"
|
||||
if (trimMarginDefault != "ABC\n123\n456") return "Fail 2"
|
||||
if (withoutMargin != "XYZ\nfoo\nbar") return "Fail 3"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-30
@@ -1,30 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/constTrimMargin.kt
|
||||
PROPERTY name:trimMargin visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:trimMargin type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="123"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-trimMargin> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:trimMargin visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-trimMargin> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:trimMargin type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:trimMarginDefault visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:trimMarginDefault type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="ABC\n123\n456"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-trimMarginDefault> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:trimMarginDefault visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-trimMarginDefault> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:trimMarginDefault type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:withoutMargin visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:withoutMargin type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="XYZ\nfoo\nbar"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-withoutMargin> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:withoutMargin visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-withoutMargin> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:withoutMargin type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
@@ -6,3 +6,10 @@ const val name1 = EnumClass.OK.name
|
||||
const val name2 = EnumClass.VALUE.name
|
||||
const val name3 = EnumClass.anotherValue.name
|
||||
const val name4 = EnumClass.WITH_UNDERSCORE.name
|
||||
|
||||
fun box(): String {
|
||||
if (name2 != "VALUE") return "Fail 1"
|
||||
if (name3 != "anotherValue") return "Fail 2"
|
||||
if (name4 != "WITH_UNDERSCORE") return "Fail 3"
|
||||
return name1
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/enumName.kt
|
||||
CLASS ENUM_CLASS name:EnumClass modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.EnumClass>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.EnumClass
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.EnumClass [primary]
|
||||
BLOCK_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <root>.EnumClass
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:EnumClass modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.EnumClass>]'
|
||||
ENUM_ENTRY name:OK
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.EnumClass'
|
||||
ENUM_ENTRY name:VALUE
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.EnumClass'
|
||||
ENUM_ENTRY name:anotherValue
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.EnumClass'
|
||||
ENUM_ENTRY name:WITH_UNDERSCORE
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.EnumClass'
|
||||
PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
annotations:
|
||||
Foldable
|
||||
overridden:
|
||||
public final name: kotlin.String [val]
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final ordinal: kotlin.Int [val]
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Any [fake_override]
|
||||
overridden:
|
||||
protected final fun clone (): kotlin.Any declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>, other:<root>.EnumClass) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.EnumClass
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Unit [fake_override]
|
||||
overridden:
|
||||
protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:@[FlexibleNullability] java.lang.Class<@[FlexibleNullability] <root>.EnumClass?>? [fake_override]
|
||||
overridden:
|
||||
public final fun getDeclaringClass (): @[FlexibleNullability] java.lang.Class<@[FlexibleNullability] E of kotlin.Enum?>? declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.EnumClass>
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.EnumClass
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||
PROPERTY name:name1 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:name1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="OK"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-name1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:name1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-name1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:name2 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:name2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="VALUE"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-name2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:name2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-name2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:name3 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:name3 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="anotherValue"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-name3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:name3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-name3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name3 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:name4 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:name4 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="WITH_UNDERSCORE"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-name4> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:name4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-name4> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name4 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
@@ -15,3 +15,12 @@ const val withWhen3 = when(value) {
|
||||
else -> "3"
|
||||
}
|
||||
const val multibranchIf = if (value == 100) 1 else if (value == 1000) 2 else 3
|
||||
|
||||
fun box(): String {
|
||||
if (condition != "True") return "Fail 1"
|
||||
if (withWhen != "True") return "Fail 2"
|
||||
if (withWhen2 != "True") return "Fail 3"
|
||||
if (withWhen3 != "1") return "Fail 4"
|
||||
if (multibranchIf != 3) return "Fail 5"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/ifConstVal.kt
|
||||
PROPERTY name:flag visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:flag type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-flag> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:flag visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-flag> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:flag type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
PROPERTY name:value visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=10
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:condition visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:condition type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="True"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-condition> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:condition visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-condition> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:condition type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:withWhen visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:withWhen type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="True"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-withWhen> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:withWhen visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-withWhen> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:withWhen type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:withWhen2 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:withWhen2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="True"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-withWhen2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:withWhen2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-withWhen2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:withWhen2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:withWhen3 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:withWhen3 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-withWhen3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:withWhen3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-withWhen3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:withWhen3 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:multibranchIf visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:multibranchIf type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-multibranchIf> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:multibranchIf visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-multibranchIf> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:multibranchIf type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
@@ -8,3 +8,12 @@ const val propertyName2 = A::somePropertyWithLongName.name
|
||||
const val methodName = A::foo.name
|
||||
const val className = ::A.name
|
||||
const val topLevelPropName = ::topLevelProp.name
|
||||
|
||||
fun box(): String {
|
||||
if (propertyName1 != "OK") return "Fail 1"
|
||||
if (propertyName2 != "somePropertyWithLongName") return "Fail 2"
|
||||
if (methodName != "foo") return "Fail 3"
|
||||
if (className != "<init>") return "Fail 4"
|
||||
if (topLevelPropName != "topLevelProp") return "Fail 5"
|
||||
return "OK"
|
||||
}
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/kCallableName.kt
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> (OK:kotlin.Int, somePropertyWithLongName:kotlin.String) returnType:<root>.A [primary]
|
||||
VALUE_PARAMETER name:OK index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:somePropertyWithLongName index:1 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
PROPERTY name:OK visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:OK type:kotlin.Int visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'OK: kotlin.Int declared in <root>.A.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-OK> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:OK visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-OK> (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:OK type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-OK>' type=<root>.A origin=null
|
||||
PROPERTY name:somePropertyWithLongName visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:somePropertyWithLongName type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'somePropertyWithLongName: kotlin.String declared in <root>.A.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-somePropertyWithLongName> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:somePropertyWithLongName visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-somePropertyWithLongName> (): kotlin.String declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:somePropertyWithLongName type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-somePropertyWithLongName>' type=<root>.A origin=null
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
PROPERTY name:topLevelProp visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:topLevelProp type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-topLevelProp> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:topLevelProp visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-topLevelProp> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:topLevelProp type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:propertyName1 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:propertyName1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="OK"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-propertyName1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:propertyName1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-propertyName1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:propertyName1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:propertyName2 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:propertyName2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="somePropertyWithLongName"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-propertyName2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:propertyName2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-propertyName2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:propertyName2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:methodName visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:methodName type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="foo"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-methodName> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:methodName visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-methodName> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:methodName type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:className visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:className type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="<init>"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-className> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:className visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-className> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:className type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:topLevelPropName visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:topLevelPropName type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="topLevelProp"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-topLevelPropName> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:topLevelPropName visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-topLevelPropName> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:topLevelPropName type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
@@ -10,6 +10,27 @@ const val toString4 = 4L.toString()
|
||||
const val toString5 = 5.0.toString()
|
||||
|
||||
const val equals1 = "1" == toString1
|
||||
const val equals2 = 2 == "2"
|
||||
const val equals3 = 3 == 3L
|
||||
const val equals4 = 4.0 == 4f
|
||||
const val equals2 = "4" == toString4
|
||||
const val equals3 = "5.0" == toString5
|
||||
const val equals4 = mul == 100L
|
||||
const val equals5 = divide == 0.5
|
||||
|
||||
fun box(): String {
|
||||
if (add != 10) return "Fail 1"
|
||||
if (concat != "1234") return "Fail 2"
|
||||
if (divide != 0.5) return "Fail 3"
|
||||
if (mul != 1000L) return "Fail 4"
|
||||
|
||||
if (toString1 != "1") return "Fail 5"
|
||||
if (toString2 != "2") return "Fail 6"
|
||||
if (toString3 != "3") return "Fail 7"
|
||||
if (toString4 != "4") return "Fail 8"
|
||||
if (toString5 != "5.0") return "Fail 9"
|
||||
|
||||
if (equals1 != true) return "Fail 10"
|
||||
if (equals2 != true) return "Fail 11"
|
||||
if (equals3 != true) return "Fail 12"
|
||||
if (equals4 != false) return "Fail 13"
|
||||
if (equals5 != true) return "Fail 14"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-120
@@ -1,120 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/primitiveOperations.kt
|
||||
PROPERTY name:add visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:add type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=10
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-add> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:add visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-add> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:add type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:concat visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:concat type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1234"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-concat> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:concat visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-concat> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:concat type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:divide visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:divide type:kotlin.Double visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Double type=kotlin.Double value=0.5
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-divide> visibility:public modality:FINAL <> () returnType:kotlin.Double
|
||||
correspondingProperty: PROPERTY name:divide visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-divide> (): kotlin.Double declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:divide type:kotlin.Double visibility:public [final,static]' type=kotlin.Double origin=null
|
||||
PROPERTY name:mul visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:mul type:kotlin.Long visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Long type=kotlin.Long value=1000
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-mul> visibility:public modality:FINAL <> () returnType:kotlin.Long
|
||||
correspondingProperty: PROPERTY name:mul visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-mul> (): kotlin.Long declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:mul type:kotlin.Long visibility:public [final,static]' type=kotlin.Long origin=null
|
||||
PROPERTY name:toString1 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:toString1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-toString1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:toString1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-toString1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:toString1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:toString2 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:toString2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="2"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-toString2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:toString2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-toString2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:toString2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:toString3 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:toString3 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="3"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-toString3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:toString3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-toString3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:toString3 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:toString4 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:toString4 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="4"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-toString4> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:toString4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-toString4> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:toString4 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:toString5 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:toString5 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="5.0"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-toString5> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:toString5 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-toString5> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:toString5 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:equals1 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
PROPERTY name:equals2 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
PROPERTY name:equals3 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals3 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals3> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals3> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals3 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
PROPERTY name:equals4 visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals4 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals4> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals4> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals4 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
@@ -3,3 +3,11 @@
|
||||
const val code = '1'.code
|
||||
const val floorDiv = 10.floorDiv(2)
|
||||
const val mod = 5.mod(3)
|
||||
|
||||
fun box(): String {
|
||||
if (code != 49) return "Fail 1"
|
||||
if (floorDiv != 5) return "Fail 2"
|
||||
if (mod != 2) return "Fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
// --- IR for <main> after Evaluate functions that are marked as `Foldable`
|
||||
MODULE_FRAGMENT name:<main>
|
||||
FILE fqName:<root> fileName:/stdlibConst.kt
|
||||
PROPERTY name:code visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:code type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=49
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-code> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:code visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-code> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:code type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:floorDiv visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:floorDiv type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=5
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-floorDiv> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:floorDiv visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-floorDiv> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floorDiv type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:mod visibility:public modality:FINAL [const,val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:mod type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-mod> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:mod visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-mod> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:mod type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.backend.handlers
|
||||
|
||||
import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import org.jetbrains.kotlin.test.services.getOrCreateTempDirectory
|
||||
import java.io.File
|
||||
|
||||
class IrInterpreterDumpHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) {
|
||||
private fun getDump(): Pair<File, File>? {
|
||||
val dumpDirectory = testServices.getOrCreateTempDirectory(PhasedIrDumpHandler.DUMPED_IR_FOLDER_NAME)
|
||||
val dumpFiles = dumpDirectory.resolve(FirModuleDescriptor.FIR_MODULE_NAME.asString()).listFiles()
|
||||
val before = dumpFiles?.single { it.name.contains(PhasedIrDumpHandler.BEFORE_PREFIX) } ?: return null
|
||||
val after = dumpFiles.single { it.name.contains(PhasedIrDumpHandler.AFTER_PREFIX) } ?: return null
|
||||
return Pair(before, after)
|
||||
}
|
||||
|
||||
private fun findConstProperties(text: String): List<Int> {
|
||||
return text.split("\n")
|
||||
.mapIndexed { index: Int, line: String -> Pair(index, line) }
|
||||
.filter { it.second.trim().startsWith("PROPERTY") && it.second.contains("[const,val]") }
|
||||
.map { it.first }
|
||||
}
|
||||
|
||||
private fun checkInitializersAreConst(text: String, propertiesStart: List<Int>) {
|
||||
val lines = text.split("\n")
|
||||
for (index in propertiesStart) {
|
||||
testServices.assertions.assertTrue(lines[index + 3].trim().startsWith("CONST")) {
|
||||
"Property at $index wasn't converted to const"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) {
|
||||
if (CodegenTestDirectives.DUMP_IR_FOR_GIVEN_PHASES !in module.directives) return
|
||||
val (before, after) = getDump() ?: testServices.assertions.fail { "Cannot find BEFORE and AFTER lowering files" }
|
||||
|
||||
val beforeText = before.readText()
|
||||
val afterText = after.readText()
|
||||
val propertiesBefore = findConstProperties(beforeText)
|
||||
val propertiesAfter = findConstProperties(afterText)
|
||||
testServices.assertions.assertTrue(propertiesBefore.isNotEmpty()) { "Test file doesn't contain const properties" }
|
||||
testServices.assertions.assertEquals(propertiesBefore.size, propertiesAfter.size) {
|
||||
"After lowering some properties are missing"
|
||||
}
|
||||
|
||||
checkInitializersAreConst(afterText, propertiesAfter)
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
+2
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.getOrCreateTempDirectory
|
||||
import java.io.File
|
||||
|
||||
class PhasedIrDumpHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) {
|
||||
override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) {
|
||||
@@ -40,5 +41,6 @@ class PhasedIrDumpHandler(testServices: TestServices) : JvmBinaryArtifactHandler
|
||||
companion object {
|
||||
const val DUMPED_IR_FOLDER_NAME = "dumped_ir"
|
||||
val AFTER_PREFIX = BeforeOrAfter.AFTER.name
|
||||
val BEFORE_PREFIX = BeforeOrAfter.BEFORE.name
|
||||
}
|
||||
}
|
||||
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.runners.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.constEvaluationPhase
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.backend.handlers.PhasedIrDumpHandler
|
||||
import org.jetbrains.kotlin.test.builders.*
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR_FOR_GIVEN_PHASES
|
||||
import org.jetbrains.kotlin.test.model.ArtifactKinds
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
|
||||
open class AbstractDumpLoweredIrTest: AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
artifactKind = ArtifactKinds.Jvm
|
||||
targetBackend = TargetBackend.JVM_IR
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator
|
||||
)
|
||||
|
||||
forTestsMatching("compiler/testData/ir/loweredIr/interpreter/*") {
|
||||
defaultDirectives {
|
||||
DUMP_IR_FOR_GIVEN_PHASES with constEvaluationPhase
|
||||
}
|
||||
}
|
||||
|
||||
classicFrontendStep()
|
||||
psi2IrStep()
|
||||
jvmIrBackendStep()
|
||||
jvmArtifactsHandlersStep {
|
||||
useHandlers(::PhasedIrDumpHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.runners.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.constEvaluationPhase
|
||||
import org.jetbrains.kotlin.test.Constructor
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.backend.handlers.IrInterpreterDumpHandler
|
||||
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
|
||||
import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.builders.configureJvmArtifactsHandlersStep
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR_FOR_GIVEN_PHASES
|
||||
import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
||||
import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.runners.codegen.AbstractJvmBlackBoxCodegenTestBase
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
|
||||
open class AbstractLoweredIrInterpreterTest : AbstractJvmBlackBoxCodegenTestBase<FirOutputArtifact, IrBackendInput>(
|
||||
FrontendKinds.FIR,
|
||||
TargetBackend.JVM_IR
|
||||
) {
|
||||
override val frontendFacade: Constructor<FrontendFacade<FirOutputArtifact>>
|
||||
get() = ::FirFrontendFacade
|
||||
|
||||
override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<FirOutputArtifact, IrBackendInput>>
|
||||
get() = ::Fir2IrResultsConverter
|
||||
|
||||
override val backendFacade: Constructor<BackendFacade<IrBackendInput, BinaryArtifacts.Jvm>>
|
||||
get() = ::JvmIrBackendFacade
|
||||
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
with(builder) {
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator
|
||||
)
|
||||
|
||||
forTestsMatching("compiler/testData/ir/loweredIr/interpreter/*") {
|
||||
defaultDirectives {
|
||||
DUMP_IR_FOR_GIVEN_PHASES with constEvaluationPhase
|
||||
}
|
||||
}
|
||||
|
||||
configureJvmArtifactsHandlersStep {
|
||||
useHandlers(::IrInterpreterDumpHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.generators.util.TestGeneratorUtil
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.runners.*
|
||||
import org.jetbrains.kotlin.test.runners.codegen.*
|
||||
import org.jetbrains.kotlin.test.runners.ir.AbstractDumpLoweredIrTest
|
||||
import org.jetbrains.kotlin.test.runners.ir.AbstractLoweredIrInterpreterTest
|
||||
import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrTextTest
|
||||
import org.jetbrains.kotlin.test.runners.ir.AbstractIrTextTest
|
||||
import org.jetbrains.kotlin.test.runners.ir.AbstractLightTreeFir2IrTextTest
|
||||
@@ -118,10 +118,6 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
|
||||
model("ir/irText")
|
||||
}
|
||||
|
||||
testClass<AbstractDumpLoweredIrTest> {
|
||||
model("ir/loweredIr")
|
||||
}
|
||||
|
||||
testClass<AbstractBytecodeTextTest> {
|
||||
model("codegen/bytecodeText")
|
||||
}
|
||||
@@ -247,6 +243,10 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
|
||||
testClass<AbstractFirLocalVariableTest> {
|
||||
model("debug/localVariables")
|
||||
}
|
||||
|
||||
testClass<AbstractLoweredIrInterpreterTest> {
|
||||
model("ir/loweredIr")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup(testsRoot = "compiler/fir/fir2ir/tests-gen", testDataRoot = "compiler/fir/fir2ir/testData") {
|
||||
|
||||
Reference in New Issue
Block a user