Add IrClass.irInline

This commit is contained in:
Dmitry Petrov
2018-08-13 14:40:17 +03:00
parent 9db2b6ffba
commit de11d9164d
8 changed files with 44 additions and 11 deletions
@@ -35,6 +35,7 @@ interface IrClass : IrSymbolDeclaration<IrClassSymbol>, IrDeclarationContainer,
val isInner: Boolean
val isData: Boolean
val isExternal: Boolean
val isInline: Boolean
val superTypes: MutableList<IrType>
@@ -43,7 +43,8 @@ class IrClassImpl(
override val isCompanion: Boolean,
override val isInner: Boolean,
override val isData: Boolean,
override val isExternal: Boolean
override val isExternal: Boolean,
override val isInline: Boolean
) :
IrDeclarationBase(startOffset, endOffset, origin),
IrClass {
@@ -61,7 +62,8 @@ class IrClassImpl(
isCompanion = symbol.descriptor.isCompanionObject,
isInner = symbol.descriptor.isInner,
isData = symbol.descriptor.isData,
isExternal = symbol.descriptor.isEffectivelyExternal()
isExternal = symbol.descriptor.isEffectivelyExternal(),
isInline = symbol.descriptor.isInline
)
constructor(
@@ -34,6 +34,7 @@ class IrLazyClass(
override val isInner: Boolean,
override val isData: Boolean,
override val isExternal: Boolean,
override val isInline: Boolean,
stubGenerator: DeclarationStubGenerator,
typeTranslator: TypeTranslator
) :
@@ -56,6 +57,7 @@ class IrLazyClass(
isInner = symbol.descriptor.isInner,
isData = symbol.descriptor.isData,
isExternal = symbol.descriptor.isEffectivelyExternal(),
isInline = symbol.descriptor.isInline,
stubGenerator = stubGenerator,
typeTranslator = TypeTranslator
)
@@ -139,7 +139,8 @@ class RenderIrElementVisitor : IrElementVisitor<String, Nothing?> {
"companion".takeIf { isCompanion },
"inner".takeIf { isInner },
"data".takeIf { isData },
"external".takeIf { isExternal }
"external".takeIf { isExternal },
"inline".takeIf { isInline }
)
override fun visitTypeAlias(declaration: IrTypeAlias, data: Nothing?): String =
+3
View File
@@ -0,0 +1,3 @@
// !LANGUAGE: +InlineClasses
inline class Test(val x: Int)
+19
View File
@@ -0,0 +1,19 @@
FILE fqName:<root> fileName:/inlineClass.kt
CLASS CLASS name:Test modality:FINAL visibility:public flags:inline superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Test flags:
CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:Test flags:primary
VALUE_PARAMETER name:x index:0 type:kotlin.Int flags:
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
INSTANCE_INITIALIZER_CALL classDescriptor='Test'
PROPERTY name:x visibility:public modality:FINAL flags:val
FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public flags:final
EXPRESSION_BODY
GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:Test) returnType:kotlin.Int flags:
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL flags:val
$this: VALUE_PARAMETER name:<this> type:Test flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-x>(): Int'
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: GET_VAR 'this@Test: Test' type=Test origin=null
@@ -99,35 +99,35 @@ FILE fqName:<root> fileName:/signedToUnsignedConversions_test.kt
BLOCK_BODY
CALL 'takeUByte(UByte): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.UByte origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UByte
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UByte>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UByte>]
CALL '<get-IMPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeUByte(UByte): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.UByte origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UByte
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UByte>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UByte>]
CALL '<get-EXPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeUShort(UShort): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.UShort origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UShort
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UShort modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UShort>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UShort modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UShort>]
CALL '<get-IMPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeUShort(UShort): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.UShort origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UShort
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UShort modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UShort>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UShort modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UShort>]
CALL '<get-BIGGER_THAN_UBYTE>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeUInt(UInt): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.UInt origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UInt
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UInt modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UInt>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UInt modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UInt>]
CALL '<get-IMPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeULong(ULong): Unit' type=kotlin.Unit origin=null
u: TYPE_OP type=kotlin.ULong origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.ULong
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:ULong modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.ULong>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:ULong modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.ULong>]
CALL '<get-IMPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CALL 'takeUBytes(vararg UByte): Unit' type=kotlin.Unit origin=null
u: VARARG type=kotlin.UByteArray varargElementType=kotlin.UByte
TYPE_OP type=kotlin.UByte origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UByte
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UByte>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UByte>]
CALL '<get-IMPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
TYPE_OP type=kotlin.UByte origin=IMPLICIT_INTEGER_COERCION typeOperand=kotlin.UByte
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags: superTypes:[kotlin.Comparable<kotlin.UByte>]
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:UByte modality:FINAL visibility:public flags:inline superTypes:[kotlin.Comparable<kotlin.UByte>]
CALL '<get-EXPLICIT_INT>(): Int' type=kotlin.Int origin=GET_PROPERTY
CONST Byte type=kotlin.UByte value=42
CALL 'takeLong(Long): Unit' type=kotlin.Unit origin=null
@@ -131,6 +131,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/classes/initVar.kt");
}
@TestMetadata("inlineClass.kt")
public void testInlineClass() throws Exception {
runTest("compiler/testData/ir/irText/classes/inlineClass.kt");
}
@TestMetadata("innerClass.kt")
public void testInnerClass() throws Exception {
runTest("compiler/testData/ir/irText/classes/innerClass.kt");