diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt index fb3c72455ff..0f6e08eed06 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt @@ -206,10 +206,13 @@ class IrBuiltInsOverFir( IrConstructorCallImpl.Companion.fromSymbolOwner(intrinsicConst.defaultType, constructor) } + private val iterator by loadClass(StandardClassIds.Iterator) + override val iteratorClass: IrClassSymbol get() = iterator.klass + private val array by createClass(kotlinIrPackage, IdSignatureValues.array) { configureSuperTypes() val typeParameter = addTypeParameter("T", anyNType) - addArrayMembers(typeParameter.defaultType) + addArrayMembers(typeParameter.defaultType, iteratorClass.typeWith(typeParameter.defaultType)) finalizeClassDefinition() } override val arrayClass: IrClassSymbol get() = array.klass @@ -234,8 +237,6 @@ class IrBuiltInsOverFir( private val iterable by loadClass(StandardClassIds.Iterable) override val iterableClass: IrClassSymbol get() = iterable.klass - private val iterator by loadClass(StandardClassIds.Iterator) - override val iteratorClass: IrClassSymbol get() = iterator.klass private val listIterator by loadClass(StandardClassIds.ListIterator) override val listIteratorClass: IrClassSymbol get() = listIterator.klass private val mutableCollection by loadClass(StandardClassIds.MutableCollection) @@ -323,14 +324,26 @@ class IrBuiltInsOverFir( else -> intType } - private val _booleanArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BOOLEAN) - private val _charArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.CHAR) - private val _byteArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BYTE) - private val _shortArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.SHORT) - private val _intArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.INT) - private val _longArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.LONG) - private val _floatArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.FLOAT) - private val _doubleArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.DOUBLE) + private fun primitiveIterator(primitiveType: PrimitiveType) = + loadClass(ClassId(StandardClassIds.BASE_COLLECTIONS_PACKAGE, Name.identifier("${primitiveType.typeName}Iterator"))) + + private val booleanIterator by primitiveIterator(PrimitiveType.BOOLEAN) + private val charIterator by primitiveIterator(PrimitiveType.CHAR) + private val byteIterator by primitiveIterator(PrimitiveType.BYTE) + private val shortIterator by primitiveIterator(PrimitiveType.SHORT) + private val intIterator by primitiveIterator(PrimitiveType.INT) + private val longIterator by primitiveIterator(PrimitiveType.LONG) + private val floatIterator by primitiveIterator(PrimitiveType.FLOAT) + private val doubleIterator by primitiveIterator(PrimitiveType.DOUBLE) + + private val _booleanArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BOOLEAN, booleanIterator) + private val _charArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.CHAR, charIterator) + private val _byteArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BYTE, byteIterator) + private val _shortArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.SHORT, shortIterator) + private val _intArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.INT, intIterator) + private val _longArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.LONG, longIterator) + private val _floatArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.FLOAT, floatIterator) + private val _doubleArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.DOUBLE, doubleIterator) override val booleanArray: IrClassSymbol get() = _booleanArray.klass override val charArray: IrClassSymbol get() = _charArray.klass @@ -921,7 +934,7 @@ class IrBuiltInsOverFir( return components.symbolTable.declareSimpleFunction(signature, { IrSimpleFunctionPublicSymbolImpl(signature, null) }, ::makeWithSymbol) } - private fun IrClass.addArrayMembers(elementType: IrType) { + private fun IrClass.addArrayMembers(elementType: IrType, iteratorType: IrType) { addConstructor { origin = object : IrDeclarationOriginImpl("BUILTIN_CLASS_CONSTRUCTOR") {} returnType = defaultType @@ -932,6 +945,7 @@ class IrBuiltInsOverFir( createMemberFunction(OperatorNameConventions.GET, elementType, "index" to intType, isOperator = true, isIntrinsicConst = false) createMemberFunction(OperatorNameConventions.SET, unitType, "index" to intType, "value" to elementType, isOperator = true, isIntrinsicConst = false) createProperty("size", intType) + createMemberFunction(OperatorNameConventions.ITERATOR, iteratorType, isOperator = true) } private fun IrClass.createProperty( @@ -1064,7 +1078,7 @@ class IrBuiltInsOverFir( private fun createPrimitiveArrayClass( parent: IrDeclarationParent, primitiveType: PrimitiveType, - lazyContents: (IrClass.() -> Unit)? = null + primitiveIterator: BuiltInClassValue ) = createClass( parent, @@ -1072,8 +1086,8 @@ class IrBuiltInsOverFir( build = { modality = Modality.FINAL } ) { configureSuperTypes() - addArrayMembers(primitiveTypeToIrType[primitiveType]!!) - lazyContents?.invoke(this) + primitiveIterator.ensureLazyContentsCreated() + addArrayMembers(primitiveTypeToIrType[primitiveType]!!, primitiveIterator.type) finalizeClassDefinition() } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index cac5485ef83..e251a2c6587 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -3102,6 +3102,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("arraysFromBuiltins.kt") + public void testArraysFromBuiltins() throws Exception { + runTest("compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt"); + } + @Test @TestMetadata("builtinMap.kt") public void testBuiltinMap() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index 6098feaf0ce..004c2c9388e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -3102,6 +3102,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("arraysFromBuiltins.kt") + public void testArraysFromBuiltins() throws Exception { + runTest("compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt"); + } + @Test @TestMetadata("builtinMap.kt") public void testBuiltinMap() throws Exception { diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.fir.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.fir.ir.txt new file mode 100644 index 00000000000..290c5b408ad --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.fir.ir.txt @@ -0,0 +1,33 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Array modality:FINAL visibility:public superTypes:[kotlin.Any; kotlin.Cloneable; java.io.Serializable] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.Array + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR BUILTIN_CLASS_CONSTRUCTOR visibility:public <> (size:kotlin.Int) returnType:kotlin.Array [primary] + VALUE_PARAMETER BUILTIN_CLASS_CONSTRUCTOR name:size index:0 type:kotlin.Int + FUN BUILTIN_CLASS_METHOD name:get visibility:public modality:FINAL <> ($this:kotlin.Array, index:kotlin.Int) returnType:T of kotlin.Array [operator] + $this: VALUE_PARAMETER name:$this type:kotlin.Array + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:index index:0 type:kotlin.Int + FUN BUILTIN_CLASS_METHOD name:set visibility:public modality:FINAL <> ($this:kotlin.Array, index:kotlin.Int, value:T of kotlin.Array) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name:$this type:kotlin.Array + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:index index:0 type:kotlin.Int + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:value index:1 type:T of kotlin.Array + PROPERTY name:size visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($this:kotlin.Array) returnType:kotlin.Int + correspondingProperty: PROPERTY name:size visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:$this type:kotlin.Array + FUN BUILTIN_CLASS_METHOD name:iterator visibility:public modality:FINAL <> ($this:kotlin.Array) returnType:kotlin.collections.Iterator [operator] + annotations: + IntrinsicConstEvaluation + $this: VALUE_PARAMETER name:$this type:kotlin.Array + 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 BUILTIN_CLASS_METHOD 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 diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.ir.txt new file mode 100644 index 00000000000..b8fd88c41be --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.Array.ir.txt @@ -0,0 +1,39 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Array modality:FINAL visibility:public superTypes:[kotlin.Any; kotlin.Cloneable; java.io.Serializable] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + TYPE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <> (size:kotlin.Int, init:kotlin.Function1) returnType:kotlin.Array + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:size index:0 type:kotlin.Int + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:init index:1 type:kotlin.Function1 + PROPERTY IR_EXTERNAL_DECLARATION_STUB name:size visibility:public modality:FINAL [val] + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.Array) returnType:kotlin.Int + correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:size visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + FUN IR_EXTERNAL_DECLARATION_STUB name:clone visibility:public modality:OPEN <> ($this:kotlin.Array) returnType:kotlin.Array + overridden: + protected open fun clone (): kotlin.Any declared in kotlin.Cloneable + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + 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 + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:other index:0 type:kotlin.Any? + FUN IR_EXTERNAL_DECLARATION_STUB name:get visibility:public modality:FINAL <> ($this:kotlin.Array, index:kotlin.Int) returnType:T of kotlin.Array [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:index index:0 type:kotlin.Int + 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 + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + FUN IR_EXTERNAL_DECLARATION_STUB name:iterator visibility:public modality:FINAL <> ($this:kotlin.Array) returnType:kotlin.collections.Iterator [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + FUN IR_EXTERNAL_DECLARATION_STUB name:set visibility:public modality:FINAL <> ($this:kotlin.Array, index:kotlin.Int, value:T of kotlin.Array) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Array + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:index index:0 type:kotlin.Int + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:value index:1 type:T of kotlin.Array + 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 + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.fir.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.fir.ir.txt new file mode 100644 index 00000000000..b06fbfaf9f9 --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.fir.ir.txt @@ -0,0 +1,32 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:IntArray modality:FINAL visibility:public superTypes:[kotlin.Any; kotlin.Cloneable; java.io.Serializable] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.IntArray + CONSTRUCTOR BUILTIN_CLASS_CONSTRUCTOR visibility:public <> (size:kotlin.Int) returnType:kotlin.IntArray [primary] + VALUE_PARAMETER BUILTIN_CLASS_CONSTRUCTOR name:size index:0 type:kotlin.Int + FUN BUILTIN_CLASS_METHOD name:get visibility:public modality:FINAL <> ($this:kotlin.IntArray, index:kotlin.Int) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name:$this type:kotlin.IntArray + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:index index:0 type:kotlin.Int + FUN BUILTIN_CLASS_METHOD name:set visibility:public modality:FINAL <> ($this:kotlin.IntArray, index:kotlin.Int, value:kotlin.Int) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name:$this type:kotlin.IntArray + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:index index:0 type:kotlin.Int + VALUE_PARAMETER BUILTIN_CLASS_METHOD name:value index:1 type:kotlin.Int + PROPERTY name:size visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($this:kotlin.IntArray) returnType:kotlin.Int + correspondingProperty: PROPERTY name:size visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:$this type:kotlin.IntArray + FUN BUILTIN_CLASS_METHOD name:iterator visibility:public modality:FINAL <> ($this:kotlin.IntArray) returnType:kotlin.collections.IntIterator [operator] + annotations: + IntrinsicConstEvaluation + $this: VALUE_PARAMETER name:$this type:kotlin.IntArray + 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 BUILTIN_CLASS_METHOD 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 diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.ir.txt new file mode 100644 index 00000000000..a6556a40060 --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.IntArray.ir.txt @@ -0,0 +1,40 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:IntArray modality:FINAL visibility:public superTypes:[kotlin.Any; kotlin.Cloneable; java.io.Serializable] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <> (size:kotlin.Int, init:kotlin.Function1) returnType:kotlin.IntArray + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:size index:0 type:kotlin.Int + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:init index:1 type:kotlin.Function1 + CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <> (size:kotlin.Int) returnType:kotlin.IntArray [primary] + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:size index:0 type:kotlin.Int + PROPERTY IR_EXTERNAL_DECLARATION_STUB name:size visibility:public modality:FINAL [val] + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.IntArray) returnType:kotlin.Int + correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:size visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + FUN IR_EXTERNAL_DECLARATION_STUB name:clone visibility:public modality:OPEN <> ($this:kotlin.IntArray) returnType:kotlin.IntArray + overridden: + protected open fun clone (): kotlin.Any declared in kotlin.Cloneable + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + 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 + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:other index:0 type:kotlin.Any? + FUN IR_EXTERNAL_DECLARATION_STUB name:get visibility:public modality:FINAL <> ($this:kotlin.IntArray, index:kotlin.Int) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:index index:0 type:kotlin.Int + 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 + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + FUN IR_EXTERNAL_DECLARATION_STUB name:iterator visibility:public modality:FINAL <> ($this:kotlin.IntArray) returnType:kotlin.collections.IntIterator [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + FUN IR_EXTERNAL_DECLARATION_STUB name:set visibility:public modality:FINAL <> ($this:kotlin.IntArray, index:kotlin.Int, value:kotlin.Int) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.IntArray + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:index index:0 type:kotlin.Int + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:value index:1 type:kotlin.Int + 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 + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.fir.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.fir.ir.txt new file mode 100644 index 00000000000..0ec7158b74d --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.fir.ir.txt @@ -0,0 +1,26 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:IntIterator modality:ABSTRACT visibility:public superTypes:[kotlin.collections.Iterator] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.collections.IntIterator + CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <> () returnType:kotlin.collections.IntIterator [primary] + FUN IR_EXTERNAL_DECLARATION_STUB name:next visibility:public modality:FINAL <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Int [operator] + overridden: + public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.collections.IntIterator + FUN IR_EXTERNAL_DECLARATION_STUB name:nextInt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Int + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.collections.IntIterator + FUN FAKE_OVERRIDE name:hasNext visibility:public modality:ABSTRACT <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.collections.IntIterator + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.collections.IntIterator, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.collections.IntIterator + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.collections.IntIterator + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.collections.IntIterator) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.collections.IntIterator diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.ir.txt new file mode 100644 index 00000000000..5723ecf04ab --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.__kotlin.collections.IntIterator.ir.txt @@ -0,0 +1,26 @@ +CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:IntIterator modality:ABSTRACT visibility:public superTypes:[kotlin.collections.Iterator] + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.collections.IntIterator + CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <> () returnType:kotlin.collections.IntIterator [primary] + 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 [fake_override,operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hasNext visibility:public modality:ABSTRACT <> ($this:kotlin.collections.Iterator) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.collections.Iterator + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any + FUN IR_EXTERNAL_DECLARATION_STUB name:next visibility:public modality:FINAL <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Int [operator] + overridden: + public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.collections.IntIterator + FUN IR_EXTERNAL_DECLARATION_STUB name:nextInt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.IntIterator) returnType:kotlin.Int + $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.collections.IntIterator + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.ir.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.ir.txt new file mode 100644 index 00000000000..aafbfc24d5e --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.ir.txt @@ -0,0 +1,12 @@ +FILE fqName: fileName:/arraysFromBuiltins.kt + PROPERTY name:test visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.collections.IntIterator visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun iterator (): kotlin.collections.IntIterator [operator] declared in kotlin.IntArray' type=kotlin.collections.IntIterator origin=null + $this: CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int) [primary] declared in kotlin.IntArray' type=kotlin.IntArray origin=null + size: CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.collections.IntIterator + correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.IntIterator declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.collections.IntIterator visibility:private [final,static]' type=kotlin.collections.IntIterator origin=null diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt new file mode 100644 index 00000000000..de2ee8a7fbb --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt @@ -0,0 +1,7 @@ +// FIR_IDENTICAL +// DUMP_EXTERNAL_CLASS: kotlin/Array +// DUMP_EXTERNAL_CLASS: kotlin/IntArray +// DUMP_EXTERNAL_CLASS: kotlin/collections/IntIterator +// TARGET_BACKEND: JVM_IR + +val test = IntArray(1).iterator() diff --git a/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt.txt b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt.txt new file mode 100644 index 00000000000..c5e8ff68562 --- /dev/null +++ b/compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt.txt @@ -0,0 +1,3 @@ +val test: IntIterator + field = IntArray(size = 1).iterator() + get diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index a0885528b17..2e58d7afd35 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -3102,6 +3102,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("arraysFromBuiltins.kt") + public void testArraysFromBuiltins() throws Exception { + runTest("compiler/testData/ir/irText/stubs/arraysFromBuiltins.kt"); + } + @Test @TestMetadata("builtinMap.kt") public void testBuiltinMap() throws Exception {