diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index dbfe28a8177..bcc36d4566e 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -17,14 +17,9 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.backend.js.lower.inline.ModuleIndex import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrFile -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.toKotlinType import org.jetbrains.kotlin.ir.util.SymbolTable @@ -60,6 +55,7 @@ class JsIrBackendContext( data class SecondaryCtorPair(val delegate: IrSimpleFunctionSymbol, val stub: IrSimpleFunctionSymbol) val secondaryConstructorsMap = mutableMapOf() + val enumEntryToGetInstanceFunction = mutableMapOf() fun getOperatorByName(name: Name, type: IrType) = operatorMap[name]?.get(type.toKotlinType()) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index 6a78b2854b6..f23fa9c3a59 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -88,6 +88,8 @@ private fun JsIrBackendContext.lower(file: IrFile) { DefaultArgumentStubGenerator(this).runOnFilePostfix(file) DefaultParameterInjector(this).runOnFilePostfix(file) SharedVariablesLowering(this).runOnFilePostfix(file) + EnumClassLowering(this).runOnFilePostfix(file) + EnumUsageLowering(this).lower(file) ReturnableBlockLowering(this).lower(file) LocalDeclarationsLowering(this).runOnFilePostfix(file) InnerClassesLowering(this).runOnFilePostfix(file) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt index 163ccd823da..e1535adc232 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt @@ -128,6 +128,7 @@ class BridgesConstruction(val context: JsIrBackendContext) : ClassLoweringPass { // TODO: Support offsets for debug info val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.DEFINED, bridgeDescriptorForIrFunction) irFunction.createParameterDeclarations() + irFunction.returnType = bridge.returnType // TODO: Add type casts context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt new file mode 100644 index 00000000000..e281f8d2977 --- /dev/null +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt @@ -0,0 +1,339 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.ir.backend.js.lower + +import org.jetbrains.kotlin.backend.common.DeclarationContainerLoweringPass +import org.jetbrains.kotlin.backend.common.FileLoweringPass +import org.jetbrains.kotlin.backend.common.lower.createIrBuilder +import org.jetbrains.kotlin.backend.common.lower.irBlockBody +import org.jetbrains.kotlin.backend.common.lower.irIfThen +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl +import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext +import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder +import org.jetbrains.kotlin.ir.backend.js.symbols.JsSymbolBuilder +import org.jetbrains.kotlin.ir.backend.js.symbols.initialize +import org.jetbrains.kotlin.ir.backend.js.utils.createValueParameter +import org.jetbrains.kotlin.ir.builders.* +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl +import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.makeNullable +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid +import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid +import java.util.* + +class EnumUsageLowering(val context: JsIrBackendContext) : FileLoweringPass { + override fun lower(irFile: IrFile) { + irFile.transformChildrenVoid(object : IrElementTransformerVoid() { + override fun visitGetEnumValue(expression: IrGetEnumValue) = + JsIrBuilder.buildCall(context.enumEntryToGetInstanceFunction[expression.symbol]!!) + }) + } +} + +class EnumClassLowering(val context: JsIrBackendContext) : DeclarationContainerLoweringPass { + override fun lower(irDeclarationContainer: IrDeclarationContainer) { + irDeclarationContainer.declarations.transformFlat { declaration -> + if (declaration is IrClass && declaration.isEnumClass) + EnumClassTransformer(context, declaration).transform() + else + listOf(declaration) + } + } +} + +class EnumClassTransformer(val context: JsIrBackendContext, private val irClass: IrClass) { + private val builder = context.createIrBuilder(irClass.symbol) + private val enumEntries = irClass.declarations.filterIsInstance() + private val loweredEnumConstructors = HashMap() + private val enumName = irClass.name.identifier + + fun transform(): List { + // Add `name` and `ordinal` parameters to enum class constructors + lowerEnumConstructorsSignature() + + // Pass these parameters to delegating constructor calls + lowerEnumConstructorsBody() + + // Create instance variable for each enum entry initialized with `null` + val entryInstances = createEnumEntryInstanceVariables() + + // Lower `IrEnumConstructorCall`s inside of enum entry class constructors to corresponding `IrDelegatingConstructorCall`s. + // Add `name` and `ordinal` parameters. + lowerEnumEntryClassConstructors(entryInstances) + + // Lower `IrEnumConstructorCall`s to corresponding `IrCall`s. + // Add `name` and `ordinal` constant parameters only for calls to the "enum class" constructors ("enum entry class" constructors + // already delegate these parameters) + lowerEnumEntryInitializerExpression() + + // Create boolean flag that indicates if entry instances were initialized. + val entryInstancesInitializedVar = createEntryInstancesInitializedVar() + + // Create function that initializes all enum entry instances using `IrEnumEntry.initializationExpression`. + // It should be called on the first `IrGetEnumValue`, consecutive calls to this function will do nothing. + val initEntryInstancesFun = createInitEntryInstancesFun(entryInstancesInitializedVar, entryInstances) + + // Create entry instance getters. These are used to lower `IrGetEnumValue`. + val entryGetInstanceFuns = createGetEntryInstanceFuns(initEntryInstancesFun, entryInstances) + + // Create body for `values` and `valueOf` functions + lowerSyntheticFunctions() + + // Remove IrEnumEntry nodes from class declarations. Replace them with corresponding class declarations (if they have them). + replaceIrEntriesWithCorrespondingClasses() + + return listOf(irClass) + entryInstances + listOf(entryInstancesInitializedVar, initEntryInstancesFun) + entryGetInstanceFuns + } + + private fun createEnumValueOfBody(): IrBody { + val valueOfFun = findFunctionDescriptorForMemberWithSyntheticBodyKind(IrSyntheticBodyKind.ENUM_VALUEOF) + val nameParameter = valueOfFun.valueParameters[0] + val entryInstanceToFunction = context.enumEntryToGetInstanceFunction + + return context.createIrBuilder(valueOfFun.symbol).run { + irBlockBody { + +irReturn( + irWhen( + irClass.defaultType, + enumEntries.map { + val getInstance = entryInstanceToFunction[it.symbol]!! + irBranch( + irEquals(irString(it.name.identifier), irGet(nameParameter)), irCall(getInstance) + ) + } + irElseBranch(irCall(context.irBuiltIns.throwIseSymbol)) + ) + ) + } + } + } + + private fun lowerEnumConstructorsSignature() { + irClass.declarations.transform { declaration -> + if (declaration is IrConstructor) { + transformEnumConstructor(declaration, irClass) + } else + declaration + } + } + + private fun lowerEnumConstructorsBody() { + irClass.declarations.filterIsInstance().forEach { + IrEnumClassConstructorTransformer(it).transformBody() + } + } + + private fun lowerEnumEntryClassConstructors(entryInstances: List) { + for ((entry, instance) in enumEntries.zip(entryInstances)) { + entry.correspondingClass?.constructors?.forEach { + it.transformChildrenVoid(IrEnumEntryClassConstructorTransformer(entry, true)) + + // Initialize entry instance at the beginning of constructor so it can be used inside constructor body + (it.body as? IrBlockBody)?.apply { + statements.add(0, context.createIrBuilder(it.symbol).run { + irSetVar(instance.symbol, irGet(entry.correspondingClass!!.thisReceiver!!)) + }) + } + } + } + } + + private fun lowerEnumEntryInitializerExpression() { + for (entry in enumEntries) { + entry.initializerExpression = + entry.initializerExpression?.transform(IrEnumEntryClassConstructorTransformer(entry, false), null) + } + } + + private fun createEnumEntryInstanceVariables() = enumEntries.map { enumEntry -> + val type = enumEntry.getType().makeNullable() + val name = "${enumName}_${enumEntry.name.identifier}_instance" + builder.run { + scope.createTemporaryVariable(irImplicitCast(irNull(), type), name) + } + } + + private fun replaceIrEntriesWithCorrespondingClasses() { + irClass.declarations.transformFlat { + listOfNotNull(if (it is IrEnumEntry) it.correspondingClass else it) + } + } + + private fun lowerSyntheticFunctions() { + irClass.transformChildrenVoid(object : IrElementTransformerVoid() { + override fun visitSyntheticBody(body: IrSyntheticBody): IrBody { + return when (body.kind) { + IrSyntheticBodyKind.ENUM_VALUES -> builder.irBlockBody { } // TODO: Implement + IrSyntheticBodyKind.ENUM_VALUEOF -> createEnumValueOfBody() + } + } + }) + } + + private fun createGetEntryInstanceFuns( + initEntryInstancesFun: IrFunctionImpl, + entryInstances: List + ) = enumEntries.mapIndexed { index, enumEntry -> + buildFunction( + name = "${enumName}_${enumEntry.name.identifier}_getInstance", + returnType = enumEntry.getType() + ) { + +irCall(initEntryInstancesFun) + +irReturn(irGet(entryInstances[index])) + }.apply { + context.enumEntryToGetInstanceFunction[enumEntry.symbol] = this@apply.symbol + } + } + + private fun createInitEntryInstancesFun( + entryInstancesInitializedVar: IrVariable, + entryInstances: List + ) = buildFunction("${enumName}_initEntries") { + +irIfThen(irGet(entryInstancesInitializedVar), irReturnUnit()) + +irSetVar(entryInstancesInitializedVar.symbol, irBoolean(true)) + for ((entry, instanceVar) in enumEntries.zip(entryInstances)) { + +irSetVar(instanceVar.symbol, entry.initializerExpression!!) + } + } + + private fun createEntryInstancesInitializedVar(): IrVariable { + return builder.scope.createTemporaryVariable( + builder.irBoolean(false), + "${enumName}_entriesInitialized" + ) + } + + private inner class IrEnumClassConstructorTransformer(val constructor: IrConstructor) : IrElementTransformerVoid() { + val builder = context.createIrBuilder(constructor.symbol) + + fun transformBody() { + constructor.body?.transformChildrenVoid(this) + } + + override fun visitEnumConstructorCall(expression: IrEnumConstructorCall) = + builder.irDelegatingConstructorCall(expression.symbol.owner).apply { + for (i in 0..1) { + putValueArgument(i, builder.irGet(constructor.valueParameters[i])) + } + } + + override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression { + var constructor = expression.symbol.owner + val constructorWasTransformed = constructor.symbol in loweredEnumConstructors + + if (constructorWasTransformed) + constructor = loweredEnumConstructors[constructor.symbol]!! + + return builder.irDelegatingConstructorCall(constructor).apply { + var valueArgIdx = 0 + for (i in 0..1) { + putValueArgument(valueArgIdx++, builder.irGet(constructor.valueParameters[i])) + } + for (i in 0 until expression.valueArgumentsCount) { + putValueArgument(valueArgIdx++, expression.getValueArgument(i)) + } + } + } + } + + private inner class IrEnumEntryClassConstructorTransformer(val entry: IrEnumEntry, val isInsideConstructor: Boolean) : + IrElementTransformerVoid() { + + private fun buildConstructorCall(constructor: IrConstructor) = + if (isInsideConstructor) + builder.irDelegatingConstructorCall(constructor) + else + builder.irCall(constructor) + + override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrExpression { + var constructor = expression.symbol.owner + val constructorWasTransformed = constructor.symbol in loweredEnumConstructors + + // Enum entry class constructors are not transformed + if (constructorWasTransformed) + constructor = loweredEnumConstructors[constructor.symbol]!! + + return buildConstructorCall(constructor).apply { + var valueArgIdx = 0 + + // Enum entry class constructors already delegate name and ordinal parameters in their body + if (constructorWasTransformed) { + putValueArgument(valueArgIdx++, entry.getNameExpression()) + putValueArgument(valueArgIdx++, entry.getOrdinalExpression()) + } + for (i in 0 until expression.valueArgumentsCount) { + putValueArgument(valueArgIdx++, expression.getValueArgument(i)) + } + } + } + } + + private fun transformEnumConstructor(enumConstructor: IrConstructor, enumClass: IrClass): IrConstructor { + val loweredConstructorSymbol = lowerEnumConstructor(enumConstructor) + return IrConstructorImpl( + enumConstructor.startOffset, enumConstructor.endOffset, enumConstructor.origin, + loweredConstructorSymbol, + enumConstructor.body // will be transformed later + ).apply { + parent = enumClass + returnType = enumConstructor.returnType + createParameterDeclarations() + loweredEnumConstructors[enumConstructor.symbol] = this + } + } + + private fun lowerEnumConstructor(enumConstructor: IrConstructor): IrConstructorSymbol { + val constructorDescriptor = enumConstructor.descriptor + val loweredConstructorDescriptor = ClassConstructorDescriptorImpl.createSynthesized( + constructorDescriptor.containingDeclaration, + constructorDescriptor.annotations, + constructorDescriptor.isPrimary, + constructorDescriptor.source + ) + + val valueParameters = + listOf( + createValueParameter(loweredConstructorDescriptor, 0, "name", context.builtIns.stringType), + createValueParameter(loweredConstructorDescriptor, 1, "ordinal", context.builtIns.intType) + ) + constructorDescriptor.valueParameters.map { + it.copy(loweredConstructorDescriptor, it.name, it.index + 2) + } + + loweredConstructorDescriptor.initialize(valueParameters, Visibilities.PROTECTED) + loweredConstructorDescriptor.returnType = constructorDescriptor.returnType + return IrConstructorSymbolImpl(loweredConstructorDescriptor) + } + + private fun findFunctionDescriptorForMemberWithSyntheticBodyKind(kind: IrSyntheticBodyKind): IrFunction = + irClass.declarations.asSequence().filterIsInstance() + .first { + it.body.let { body -> + body is IrSyntheticBody && body.kind == kind + } + } + + private fun buildFunction( + name: String, + returnType: IrType = context.irBuiltIns.unitType, + bodyBuilder: IrBlockBodyBuilder.() -> Unit + ) = JsIrBuilder.buildFunction( + symbol = JsSymbolBuilder.buildSimpleFunction(irClass.descriptor.containingDeclaration, name) + .initialize(returnType = returnType), + returnType = returnType + ).apply { + body = context.createIrBuilder(this.symbol).irBlockBody(this, bodyBuilder) + } + + private fun IrEnumEntry.getNameExpression() = builder.irString(this.name.identifier) + private fun IrEnumEntry.getOrdinalExpression() = builder.irInt(enumEntries.indexOf(this)) + private fun IrEnumEntry.getType() = (correspondingClass ?: irClass).defaultType +} diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt index ed0a789f9a5..28010499503 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt @@ -174,7 +174,7 @@ class SecondaryCtorLowering(val context: JsIrBackendContext) : IrElementTransfor typeParameters += ctorOrig.typeParameters // parent = ctorOrig.parent - val returnType = type + returnType = type val createFunctionIntrinsic = context.intrinsics.jsObjectCreate val irCreateCall = JsIrBuilder.buildCall( createFunctionIntrinsic.symbol, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt index e9ccb083666..f7bf2f74e2c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt @@ -8,16 +8,10 @@ package org.jetbrains.kotlin.ir.builders import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.declarations.IrField -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrValueDeclaration -import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* -import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol -import org.jetbrains.kotlin.ir.symbols.IrValueSymbol -import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol +import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classifierOrFail import org.jetbrains.kotlin.utils.addToStdlib.assertedCast @@ -80,6 +74,9 @@ fun IrStatementsBuilder.defineTemporaryVar(value: IrExpressio fun IrBuilderWithScope.irExprBody(value: IrExpression) = IrExpressionBodyImpl(startOffset, endOffset, value) +fun IrBuilderWithScope.irWhen(type: IrType, branches: List) = + IrWhenImpl(startOffset, endOffset, type, null, branches) + fun IrBuilderWithScope.irReturn(value: IrExpression) = IrReturnImpl( startOffset, endOffset, @@ -93,10 +90,17 @@ fun IrBuilderWithScope.irReturn(value: IrExpression) = fun IrBuilderWithScope.irBoolean(value: Boolean) = IrConstImpl(startOffset, endOffset, context.irBuiltIns.booleanType, IrConstKind.Boolean, value) +fun IrBuilderWithScope.irUnit() = + irGetObjectValue(context.irBuiltIns.unitType, context.irBuiltIns.unitClass) + fun IrBuilderWithScope.irTrue() = irBoolean(true) fun IrBuilderWithScope.irFalse() = irBoolean(false) fun IrBuilderWithScope.irReturnTrue() = irReturn(irTrue()) fun IrBuilderWithScope.irReturnFalse() = irReturn(irFalse()) +fun IrBuilderWithScope.irReturnUnit() = irReturn(irUnit()) + +fun IrBuilderWithScope.irBranch(condition: IrExpression, result: IrExpression) = + IrBranchImpl(startOffset, endOffset, condition, result) fun IrBuilderWithScope.irElseBranch(expression: IrExpression) = IrElseBranchImpl(startOffset, endOffset, irTrue(), expression) @@ -141,6 +145,9 @@ fun IrBuilderWithScope.irSetVar(variable: IrVariableSymbol, value: IrExpression) fun IrBuilderWithScope.irGetField(receiver: IrExpression?, field: IrField) = IrGetFieldImpl(startOffset, endOffset, field.symbol, field.type, receiver) +fun IrBuilderWithScope.irGetObjectValue(type: IrType, classSymbol: IrClassSymbol) = + IrGetObjectValueImpl(startOffset, endOffset, type, classSymbol) + fun IrBuilderWithScope.irEqeqeq(arg1: IrExpression, arg2: IrExpression) = context.eqeqeq(startOffset, endOffset, arg1, arg2) @@ -153,13 +160,16 @@ fun IrBuilderWithScope.irEqualsNull(argument: IrExpression) = argument, irNull() ) +fun IrBuilderWithScope.irEquals(arg1: IrExpression, arg2: IrExpression) = + primitiveOp2( + startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EXCLEQ, + arg1, arg2 + ) + fun IrBuilderWithScope.irNotEquals(arg1: IrExpression, arg2: IrExpression) = primitiveOp1( startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, IrStatementOrigin.EXCLEQ, - primitiveOp2( - startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EXCLEQ, - arg1, arg2 - ) + irEquals(arg1, arg2) ) fun IrBuilderWithScope.irGet(type: IrType, receiver: IrExpression, getterSymbol: IrFunctionSymbol): IrCall = @@ -185,6 +195,8 @@ fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, descriptor: FunctionDesc fun IrBuilderWithScope.irCall(callee: IrFunction): IrCall = irCall(callee.symbol, callee.descriptor, callee.returnType) +fun IrBuilderWithScope.irDelegatingConstructorCall(callee: IrConstructor): IrDelegatingConstructorCall = + IrDelegatingConstructorCallImpl(startOffset, endOffset, callee.returnType, callee.symbol, callee.descriptor, callee.typeParameters.size) fun IrBuilderWithScope.irCallOp( callee: IrFunctionSymbol, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt index c3d9d5decc1..a0ccf1a4304 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt @@ -147,6 +147,7 @@ class IrBuiltIns( val eqeqFun = defineOperator("EQEQ", bool, listOf(anyN, anyN)) val throwNpeFun = defineOperator("THROW_NPE", nothing, listOf()) val throwCceFun = defineOperator("THROW_CCE", nothing, listOf()) + val throwIseFun = defineOperator("THROW_ISE", nothing, listOf()) val booleanNotFun = defineOperator("NOT", bool, listOf(bool)) val noWhenBranchMatchedExceptionFun = defineOperator("noWhenBranchMatchedException", nothing, listOf()) @@ -161,6 +162,7 @@ class IrBuiltIns( val eqeqSymbol = eqeqFun.symbol val throwNpeSymbol = throwNpeFun.symbol val throwCceSymbol = throwCceFun.symbol + val throwIseSymbol = throwIseFun.symbol val booleanNotSymbol = booleanNotFun.symbol val noWhenBranchMatchedExceptionSymbol = noWhenBranchMatchedExceptionFun.symbol diff --git a/compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt b/compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt index 08071d4d79b..80393707975 100644 --- a/compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt +++ b/compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +NestedClassesInAnnotations // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR annotation class Foo(val kind: Kind) { enum class Kind { FAIL, OK } diff --git a/compiler/testData/codegen/box/bridges/simpleEnum.kt b/compiler/testData/codegen/box/bridges/simpleEnum.kt index 25e814d4c7c..0446aba8c33 100644 --- a/compiler/testData/codegen/box/bridges/simpleEnum.kt +++ b/compiler/testData/codegen/box/bridges/simpleEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR interface A { open fun foo(t: T) = "A" } diff --git a/compiler/testData/codegen/box/bridges/substitutionInSuperClass/enum.kt b/compiler/testData/codegen/box/bridges/substitutionInSuperClass/enum.kt index 74cae3ed750..243498038e6 100644 --- a/compiler/testData/codegen/box/bridges/substitutionInSuperClass/enum.kt +++ b/compiler/testData/codegen/box/bridges/substitutionInSuperClass/enum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR interface A { open fun foo(t: T) = "A" } diff --git a/compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt b/compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt index 75c5ec034cc..bab9b0ef193 100644 --- a/compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt +++ b/compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS enum class E { A, B; diff --git a/compiler/testData/codegen/box/callableReference/function/enumValueOfMethod.kt b/compiler/testData/codegen/box/callableReference/function/enumValueOfMethod.kt index a7fdcc8a01d..1e1930a08d0 100644 --- a/compiler/testData/codegen/box/callableReference/function/enumValueOfMethod.kt +++ b/compiler/testData/codegen/box/callableReference/function/enumValueOfMethod.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class E { ENTRY } diff --git a/compiler/testData/codegen/box/callableReference/function/local/enumExtendsTrait.kt b/compiler/testData/codegen/box/callableReference/function/local/enumExtendsTrait.kt index a913cc2b880..5ae74283aee 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/enumExtendsTrait.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/enumExtendsTrait.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR interface Named { val name: String } diff --git a/compiler/testData/codegen/box/callableReference/property/enumNameOrdinal.kt b/compiler/testData/codegen/box/callableReference/property/enumNameOrdinal.kt index 471852fcea4..fc156fb6304 100644 --- a/compiler/testData/codegen/box/callableReference/property/enumNameOrdinal.kt +++ b/compiler/testData/codegen/box/callableReference/property/enumNameOrdinal.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class E { I } diff --git a/compiler/testData/codegen/box/classes/kt2626.kt b/compiler/testData/codegen/box/classes/kt2626.kt index a0e6130c6f8..34ba1d2ad8d 100644 --- a/compiler/testData/codegen/box/classes/kt2626.kt +++ b/compiler/testData/codegen/box/classes/kt2626.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package example2 fun box() = Context.OsType.OK.toString() diff --git a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerEnumEntryCapturedInLambdaInInnerClass.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerEnumEntryCapturedInLambdaInInnerClass.kt index 1da0d428e8f..5e7c1014361 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerEnumEntryCapturedInLambdaInInnerClass.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerEnumEntryCapturedInLambdaInInnerClass.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR abstract class Base(val fn: () -> Test) enum class Test(val ok: String) { diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt index 232fbb2fa47..6491d8e0cc9 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A { ONE, TWO; diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt index 6ac11aae25d..95eb4b9c827 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A { ONE, TWO diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt index 8410164c632..d627dad85a8 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR import A.ONE enum class A { diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt index 063309e6a26..53ecfc65908 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR import A.ONE enum class A { diff --git a/compiler/testData/codegen/box/enum/abstractMethodInEnum.kt b/compiler/testData/codegen/box/enum/abstractMethodInEnum.kt index 4b52782da6d..0d3ed6de674 100644 --- a/compiler/testData/codegen/box/enum/abstractMethodInEnum.kt +++ b/compiler/testData/codegen/box/enum/abstractMethodInEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A() { ENTRY(){ override fun t() = "OK"}; diff --git a/compiler/testData/codegen/box/enum/abstractNestedClass.kt b/compiler/testData/codegen/box/enum/abstractNestedClass.kt index 430c0c69e88..3994bd54e17 100644 --- a/compiler/testData/codegen/box/enum/abstractNestedClass.kt +++ b/compiler/testData/codegen/box/enum/abstractNestedClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class E { ENTRY; diff --git a/compiler/testData/codegen/box/enum/asReturnExpression.kt b/compiler/testData/codegen/box/enum/asReturnExpression.kt index 5370742a403..c001e02763a 100644 --- a/compiler/testData/codegen/box/enum/asReturnExpression.kt +++ b/compiler/testData/codegen/box/enum/asReturnExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // http://youtrack.jetbrains.com/issue/KT-2167 enum class Season { diff --git a/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt b/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt index 76a7a0a85cf..d8a2035b3a3 100644 --- a/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt +++ b/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class A { diff --git a/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass2.kt b/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass2.kt index 3666fef1c4c..a751690a380 100644 --- a/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass2.kt +++ b/compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass2.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class A { diff --git a/compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithDefaultArguments.kt b/compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithDefaultArguments.kt index f3637788abd..fb08b98daab 100644 --- a/compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithDefaultArguments.kt +++ b/compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithDefaultArguments.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Test(val x: Int, val str: String) { OK; constructor(x: Int = 0) : this(x, "OK") diff --git a/compiler/testData/codegen/box/enum/emptyConstructor.kt b/compiler/testData/codegen/box/enum/emptyConstructor.kt index 908e6882c4f..c82a4ac41c3 100644 --- a/compiler/testData/codegen/box/enum/emptyConstructor.kt +++ b/compiler/testData/codegen/box/enum/emptyConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package test enum class My(val s: String) { diff --git a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt index e497488c6ef..7fce90cfd7f 100644 --- a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt +++ b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR interface IFoo { fun foo(): String } diff --git a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt index 6166821cc61..4a06775ea0d 100644 --- a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt +++ b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR interface IFoo { fun foo(): String } diff --git a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt index a6a95e7c36f..b43334323c0 100644 --- a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt +++ b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR interface IFoo { fun foo(): String } diff --git a/compiler/testData/codegen/box/enum/enumInheritedFromTrait.kt b/compiler/testData/codegen/box/enum/enumInheritedFromTrait.kt index f134014ce62..8171865caed 100644 --- a/compiler/testData/codegen/box/enum/enumInheritedFromTrait.kt +++ b/compiler/testData/codegen/box/enum/enumInheritedFromTrait.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package test fun box() = MyEnum.E1.f() + MyEnum.E2.f() diff --git a/compiler/testData/codegen/box/enum/enumShort.kt b/compiler/testData/codegen/box/enum/enumShort.kt index 906c2b4bc8b..78935006d2b 100644 --- a/compiler/testData/codegen/box/enum/enumShort.kt +++ b/compiler/testData/codegen/box/enum/enumShort.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Color(val rgb: Int) { RED(0xff0000), GREEN(0x00ff00), diff --git a/compiler/testData/codegen/box/enum/inPackage.kt b/compiler/testData/codegen/box/enum/inPackage.kt index 56309762daf..388eb0a0dd3 100644 --- a/compiler/testData/codegen/box/enum/inPackage.kt +++ b/compiler/testData/codegen/box/enum/inPackage.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package test enum class Season { diff --git a/compiler/testData/codegen/box/enum/inclassobj.kt b/compiler/testData/codegen/box/enum/inclassobj.kt index 23b1e004504..5006013d4b7 100644 --- a/compiler/testData/codegen/box/enum/inclassobj.kt +++ b/compiler/testData/codegen/box/enum/inclassobj.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box() = if(Context.operatingSystemType == Context.Companion.OsType.OTHER) "OK" else "fail" public class Context diff --git a/compiler/testData/codegen/box/enum/inner.kt b/compiler/testData/codegen/box/enum/inner.kt index 9b6b9906c6b..01ef380fbc3 100644 --- a/compiler/testData/codegen/box/enum/inner.kt +++ b/compiler/testData/codegen/box/enum/inner.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class A { enum class E { OK diff --git a/compiler/testData/codegen/box/enum/innerClassInEnumEntryClass.kt b/compiler/testData/codegen/box/enum/innerClassInEnumEntryClass.kt index 14c0e14f8bd..6ca116ac3c6 100644 --- a/compiler/testData/codegen/box/enum/innerClassInEnumEntryClass.kt +++ b/compiler/testData/codegen/box/enum/innerClassInEnumEntryClass.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class A { diff --git a/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass.kt b/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass.kt index a69646f7e98..c6cfd3307bf 100644 --- a/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass.kt +++ b/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class A { diff --git a/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass2.kt b/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass2.kt index 35b149c88f4..2868f51c1e0 100644 --- a/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass2.kt +++ b/compiler/testData/codegen/box/enum/innerClassMethodInEnumEntryClass2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class A { diff --git a/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt b/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt index 2fc256285ba..139345cc14a 100644 --- a/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt +++ b/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class A { companion object {} enum class E { diff --git a/compiler/testData/codegen/box/enum/kt1119.kt b/compiler/testData/codegen/box/enum/kt1119.kt index d1e9fcdd81b..6445197faee 100644 --- a/compiler/testData/codegen/box/enum/kt1119.kt +++ b/compiler/testData/codegen/box/enum/kt1119.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Direction() { NORTH { val someSpecialValue = "OK" diff --git a/compiler/testData/codegen/box/enum/kt18731.kt b/compiler/testData/codegen/box/enum/kt18731.kt index aab7b2c749f..bc98fc4c1b8 100644 --- a/compiler/testData/codegen/box/enum/kt18731.kt +++ b/compiler/testData/codegen/box/enum/kt18731.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Bar { ONE, TWO diff --git a/compiler/testData/codegen/box/enum/kt20651.kt b/compiler/testData/codegen/box/enum/kt20651.kt index eac5bd927b4..026902b2e5d 100644 --- a/compiler/testData/codegen/box/enum/kt20651.kt +++ b/compiler/testData/codegen/box/enum/kt20651.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class Test(val x: String, val closure1: () -> String) { FOO("O", { FOO.x }) { override val y: String = "K" diff --git a/compiler/testData/codegen/box/enum/kt2350.kt b/compiler/testData/codegen/box/enum/kt2350.kt index 08e1782f5ba..d4a363062b3 100644 --- a/compiler/testData/codegen/box/enum/kt2350.kt +++ b/compiler/testData/codegen/box/enum/kt2350.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A(val b: String) { E1("OK"){ override fun t() = b }; diff --git a/compiler/testData/codegen/box/enum/kt7257_anonObjectInit.kt b/compiler/testData/codegen/box/enum/kt7257_anonObjectInit.kt index 9d362335d8a..08002c4e69d 100644 --- a/compiler/testData/codegen/box/enum/kt7257_anonObjectInit.kt +++ b/compiler/testData/codegen/box/enum/kt7257_anonObjectInit.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { val value2 = "K" diff --git a/compiler/testData/codegen/box/enum/kt7257_anonObjectMethod.kt b/compiler/testData/codegen/box/enum/kt7257_anonObjectMethod.kt index 0eeaf7cce75..ed97f2ddcf8 100644 --- a/compiler/testData/codegen/box/enum/kt7257_anonObjectMethod.kt +++ b/compiler/testData/codegen/box/enum/kt7257_anonObjectMethod.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { val value2 = "K" diff --git a/compiler/testData/codegen/box/enum/kt7257_boundReference1.kt b/compiler/testData/codegen/box/enum/kt7257_boundReference1.kt index c951e306143..818388b1003 100644 --- a/compiler/testData/codegen/box/enum/kt7257_boundReference1.kt +++ b/compiler/testData/codegen/box/enum/kt7257_boundReference1.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class X { diff --git a/compiler/testData/codegen/box/enum/kt7257_boundReference2.kt b/compiler/testData/codegen/box/enum/kt7257_boundReference2.kt index 5a18186a129..b8613250066 100644 --- a/compiler/testData/codegen/box/enum/kt7257_boundReference2.kt +++ b/compiler/testData/codegen/box/enum/kt7257_boundReference2.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { diff --git a/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt b/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt index ff4a81719eb..aa74fbda119 100644 --- a/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt +++ b/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // LANGUAGE_VERSION: 1.2 enum class X { diff --git a/compiler/testData/codegen/box/enum/kt7257_explicitReceiver.kt b/compiler/testData/codegen/box/enum/kt7257_explicitReceiver.kt index 6be0ef691d0..66adf154b60 100644 --- a/compiler/testData/codegen/box/enum/kt7257_explicitReceiver.kt +++ b/compiler/testData/codegen/box/enum/kt7257_explicitReceiver.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { override val value2 = "K" diff --git a/compiler/testData/codegen/box/enum/kt7257_fullyQualifiedReceiver.kt b/compiler/testData/codegen/box/enum/kt7257_fullyQualifiedReceiver.kt index fb0291599c6..bba458aeb3c 100644 --- a/compiler/testData/codegen/box/enum/kt7257_fullyQualifiedReceiver.kt +++ b/compiler/testData/codegen/box/enum/kt7257_fullyQualifiedReceiver.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { override val value2 = "K" diff --git a/compiler/testData/codegen/box/enum/kt7257_namedLocalFun.kt b/compiler/testData/codegen/box/enum/kt7257_namedLocalFun.kt index 8b8fad27d80..713fe984c25 100644 --- a/compiler/testData/codegen/box/enum/kt7257_namedLocalFun.kt +++ b/compiler/testData/codegen/box/enum/kt7257_namedLocalFun.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { val value2 = "K" diff --git a/compiler/testData/codegen/box/enum/kt7257_notInline.kt b/compiler/testData/codegen/box/enum/kt7257_notInline.kt index 01a90397268..69e1882ef59 100644 --- a/compiler/testData/codegen/box/enum/kt7257_notInline.kt +++ b/compiler/testData/codegen/box/enum/kt7257_notInline.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR fun T.letNoInline(fn: (T) -> R) = fn(this) diff --git a/compiler/testData/codegen/box/enum/kt9711.kt b/compiler/testData/codegen/box/enum/kt9711.kt index 7c6298d9693..ce4a36c8cd4 100644 --- a/compiler/testData/codegen/box/enum/kt9711.kt +++ b/compiler/testData/codegen/box/enum/kt9711.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR enum class X { B { diff --git a/compiler/testData/codegen/box/enum/kt9711_2.kt b/compiler/testData/codegen/box/enum/kt9711_2.kt index 3eec4e993cb..8642ed92784 100644 --- a/compiler/testData/codegen/box/enum/kt9711_2.kt +++ b/compiler/testData/codegen/box/enum/kt9711_2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS diff --git a/compiler/testData/codegen/box/enum/objectInEnum.kt b/compiler/testData/codegen/box/enum/objectInEnum.kt index b0895501014..9f19d3c1704 100644 --- a/compiler/testData/codegen/box/enum/objectInEnum.kt +++ b/compiler/testData/codegen/box/enum/objectInEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class E { ENTRY, SUBCLASS { diff --git a/compiler/testData/codegen/box/enum/ordinal.kt b/compiler/testData/codegen/box/enum/ordinal.kt index 5303b21a9e5..d66c3e0ae4e 100644 --- a/compiler/testData/codegen/box/enum/ordinal.kt +++ b/compiler/testData/codegen/box/enum/ordinal.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class State { _0, _1, diff --git a/compiler/testData/codegen/box/enum/simple.kt b/compiler/testData/codegen/box/enum/simple.kt index 31549a0e202..ed48d29a5d9 100644 --- a/compiler/testData/codegen/box/enum/simple.kt +++ b/compiler/testData/codegen/box/enum/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Season { WINTER, SPRING, diff --git a/compiler/testData/codegen/box/enum/superCallInEnumLiteral.kt b/compiler/testData/codegen/box/enum/superCallInEnumLiteral.kt index 70c2cc5b9b0..11507d9d147 100644 --- a/compiler/testData/codegen/box/enum/superCallInEnumLiteral.kt +++ b/compiler/testData/codegen/box/enum/superCallInEnumLiteral.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package test fun box() = E.E1.f() + E.E2.f() diff --git a/compiler/testData/codegen/box/enum/toString.kt b/compiler/testData/codegen/box/enum/toString.kt index 808ea084597..b4890365b12 100644 --- a/compiler/testData/codegen/box/enum/toString.kt +++ b/compiler/testData/codegen/box/enum/toString.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class State { O, K diff --git a/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt b/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt index b67bddddb59..d8ae583f3d5 100644 --- a/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt +++ b/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class Outer { enum class Nested { O, diff --git a/compiler/testData/codegen/box/objects/kt1186.kt b/compiler/testData/codegen/box/objects/kt1186.kt index 0a06675a421..6100f7092fa 100644 --- a/compiler/testData/codegen/box/objects/kt1186.kt +++ b/compiler/testData/codegen/box/objects/kt1186.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Color(val rgb : Int) { RED(0xFF0000), GREEN(0x00FF00), diff --git a/compiler/testData/codegen/box/objects/kt694.kt b/compiler/testData/codegen/box/objects/kt694.kt index e3f2d0e76db..945e1298489 100644 --- a/compiler/testData/codegen/box/objects/kt694.kt +++ b/compiler/testData/codegen/box/objects/kt694.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class Test { A, B, diff --git a/compiler/testData/codegen/box/package/privateMembersInImportList.kt b/compiler/testData/codegen/box/package/privateMembersInImportList.kt index 44b068bb240..e7009753efa 100644 --- a/compiler/testData/codegen/box/package/privateMembersInImportList.kt +++ b/compiler/testData/codegen/box/package/privateMembersInImportList.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR package test import test.C.E1 diff --git a/compiler/testData/codegen/box/specialBuiltins/enumAsOrdinaled.kt b/compiler/testData/codegen/box/specialBuiltins/enumAsOrdinaled.kt index 0f13bc5fc5a..6b3eda01d77 100644 --- a/compiler/testData/codegen/box/specialBuiltins/enumAsOrdinaled.kt +++ b/compiler/testData/codegen/box/specialBuiltins/enumAsOrdinaled.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR interface Ordinaled { val ordinal: Int } diff --git a/compiler/testData/codegen/box/typealias/enumEntryQualifier.kt b/compiler/testData/codegen/box/typealias/enumEntryQualifier.kt index 8c7380b2571..19c383aaed0 100644 --- a/compiler/testData/codegen/box/typealias/enumEntryQualifier.kt +++ b/compiler/testData/codegen/box/typealias/enumEntryQualifier.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class MyEnum { O; companion object { diff --git a/compiler/testData/codegen/box/when/emptyWhen.kt b/compiler/testData/codegen/box/when/emptyWhen.kt index 4464a3c33b8..62ab58b6bf3 100644 --- a/compiler/testData/codegen/box/when/emptyWhen.kt +++ b/compiler/testData/codegen/box/when/emptyWhen.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A { X1, X2 } fun box(): String { diff --git a/compiler/testData/codegen/box/when/enumOptimization/functionLiteralInTopLevel.kt b/compiler/testData/codegen/box/when/enumOptimization/functionLiteralInTopLevel.kt index 5613881a999..eaa26cca3e3 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/functionLiteralInTopLevel.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/functionLiteralInTopLevel.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=box$lambda count=0 // CHECK_IF_COUNT: function=box$lambda count=1 diff --git a/compiler/testData/codegen/box/when/enumOptimization/kt14597.kt b/compiler/testData/codegen/box/when/enumOptimization/kt14597.kt index 8300b4ae96a..50202f79404 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/kt14597.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/kt14597.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=box count=6 // CHECK_IF_COUNT: function=box count=1 diff --git a/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt b/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt index 7ba98e03466..f69d587ee7f 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=box count=18 // CHECK_IF_COUNT: function=box count=3 diff --git a/compiler/testData/codegen/box/when/enumOptimization/kt15806.kt b/compiler/testData/codegen/box/when/enumOptimization/kt15806.kt index d3dd0f1dd92..54d4d6c5cd9 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/kt15806.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/kt15806.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=doTheThing count=2 // CHECK_IF_COUNT: function=doTheThing count=2 diff --git a/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt b/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt index 48a868e050b..f613b0c7f4f 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=box count=0 // CHECK_IF_COUNT: function=box count=1 diff --git a/compiler/testData/codegen/box/when/enumOptimization/nullableEnum.kt b/compiler/testData/codegen/box/when/enumOptimization/nullableEnum.kt index d8b8f0753fd..20d5f740782 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/nullableEnum.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/nullableEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // CHECK_CASES_COUNT: function=test count=0 // CHECK_IF_COUNT: function=test count=3 diff --git a/compiler/testData/codegen/box/when/exhaustiveWhenInitialization.kt b/compiler/testData/codegen/box/when/exhaustiveWhenInitialization.kt index ca88ea1b14b..ccf67614e6c 100644 --- a/compiler/testData/codegen/box/when/exhaustiveWhenInitialization.kt +++ b/compiler/testData/codegen/box/when/exhaustiveWhenInitialization.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A { V } fun box(): String { diff --git a/compiler/testData/codegen/box/when/exhaustiveWhenReturn.kt b/compiler/testData/codegen/box/when/exhaustiveWhenReturn.kt index 7212c709785..6b3b7658cc2 100644 --- a/compiler/testData/codegen/box/when/exhaustiveWhenReturn.kt +++ b/compiler/testData/codegen/box/when/exhaustiveWhenReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class A { V } fun box(): String { diff --git a/compiler/testData/codegen/box/when/noElseExhaustive.kt b/compiler/testData/codegen/box/when/noElseExhaustive.kt index 13475c0aa7c..e02125f19c8 100644 --- a/compiler/testData/codegen/box/when/noElseExhaustive.kt +++ b/compiler/testData/codegen/box/when/noElseExhaustive.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class En { A, B diff --git a/compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt b/compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt index 0d5a80a272c..da79d180335 100644 --- a/compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt +++ b/compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class En { A, B diff --git a/compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt b/compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt index d54fc5f9ec0..2c69069abac 100644 --- a/compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt +++ b/compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR enum class En { A, B diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.kt index 23ad84996bc..8c106c41baa 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSite.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSite.kt index d56c1d8d877..45070fe6689 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSite.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSite.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSiteComplex.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSiteComplex.kt index f29b51bddc2..a5e563681a9 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSiteComplex.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/callSiteComplex.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/declSite/complex.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/declSite/complex.kt index eb9660f18a2..70221e97c68 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/declSite/complex.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/declSite/complex.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR // FILE: 1.kt package test diff --git a/js/js.translator/testData/box/classObject/enumCompanionObject.kt b/js/js.translator/testData/box/classObject/enumCompanionObject.kt index d0b15143f7d..8da1cc53612 100644 --- a/js/js.translator/testData/box/classObject/enumCompanionObject.kt +++ b/js/js.translator/testData/box/classObject/enumCompanionObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1141 // See KT-6326, KT-6777 package foo diff --git a/js/js.translator/testData/box/closure/objectWithInvokeOperator.kt b/js/js.translator/testData/box/closure/objectWithInvokeOperator.kt index c524a3e070f..b08eadbd948 100644 --- a/js/js.translator/testData/box/closure/objectWithInvokeOperator.kt +++ b/js/js.translator/testData/box/closure/objectWithInvokeOperator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1153 package foo diff --git a/js/js.translator/testData/box/dynamic/isJsPrimitiveType.kt b/js/js.translator/testData/box/dynamic/isJsPrimitiveType.kt index 50280d5f19e..0c975f05131 100644 --- a/js/js.translator/testData/box/dynamic/isJsPrimitiveType.kt +++ b/js/js.translator/testData/box/dynamic/isJsPrimitiveType.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1148 package foo diff --git a/js/js.translator/testData/box/enum/accessing.kt b/js/js.translator/testData/box/enum/accessing.kt index e4e43c6972f..9ec9b9641e0 100644 --- a/js/js.translator/testData/box/enum/accessing.kt +++ b/js/js.translator/testData/box/enum/accessing.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1155 package foo diff --git a/js/js.translator/testData/box/enum/enumInheritedFromTrait.kt b/js/js.translator/testData/box/enum/enumInheritedFromTrait.kt index c15a6ad9cbb..17f09425bdb 100644 --- a/js/js.translator/testData/box/enum/enumInheritedFromTrait.kt +++ b/js/js.translator/testData/box/enum/enumInheritedFromTrait.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1150 package foo diff --git a/js/js.translator/testData/box/enum/enumWithInheritance.kt b/js/js.translator/testData/box/enum/enumWithInheritance.kt index 41a43b58fd8..b6b94a56d70 100644 --- a/js/js.translator/testData/box/enum/enumWithInheritance.kt +++ b/js/js.translator/testData/box/enum/enumWithInheritance.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1167 package foo diff --git a/js/js.translator/testData/box/enum/equals.kt b/js/js.translator/testData/box/enum/equals.kt index 0899cf563c0..65a957c2bb5 100644 --- a/js/js.translator/testData/box/enum/equals.kt +++ b/js/js.translator/testData/box/enum/equals.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1154 package foo diff --git a/js/js.translator/testData/box/enum/equalsNullUndefined.kt b/js/js.translator/testData/box/enum/equalsNullUndefined.kt index 2f5059f8150..52b44f3cfba 100644 --- a/js/js.translator/testData/box/enum/equalsNullUndefined.kt +++ b/js/js.translator/testData/box/enum/equalsNullUndefined.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1141 enum class A { X, diff --git a/js/js.translator/testData/box/enum/initializationOrder.kt b/js/js.translator/testData/box/enum/initializationOrder.kt index 932afdf14b7..ac74193d8ed 100644 --- a/js/js.translator/testData/box/enum/initializationOrder.kt +++ b/js/js.translator/testData/box/enum/initializationOrder.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1144 package foo diff --git a/js/js.translator/testData/box/enum/simpleEnum.kt b/js/js.translator/testData/box/enum/simpleEnum.kt index e4e5de7ba4a..a847bf18ef7 100644 --- a/js/js.translator/testData/box/enum/simpleEnum.kt +++ b/js/js.translator/testData/box/enum/simpleEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1133 package foo diff --git a/js/js.translator/testData/box/enum/superCallInEnumLiteral.kt b/js/js.translator/testData/box/enum/superCallInEnumLiteral.kt index 87d0522d5e7..d61b52d205d 100644 --- a/js/js.translator/testData/box/enum/superCallInEnumLiteral.kt +++ b/js/js.translator/testData/box/enum/superCallInEnumLiteral.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1150 package foo diff --git a/js/js.translator/testData/box/expression/when/externalEnumSubject.kt b/js/js.translator/testData/box/expression/when/externalEnumSubject.kt index 1262b16d94e..00dbe3bcd32 100644 --- a/js/js.translator/testData/box/expression/when/externalEnumSubject.kt +++ b/js/js.translator/testData/box/expression/when/externalEnumSubject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1133 external enum class X { A, B diff --git a/js/js.translator/testData/box/inline/simpleEnum.kt b/js/js.translator/testData/box/inline/simpleEnum.kt index c59df05f5fa..bbc8e47f950 100644 --- a/js/js.translator/testData/box/inline/simpleEnum.kt +++ b/js/js.translator/testData/box/inline/simpleEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1137 /* * Copy of JVM-backend test diff --git a/js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt b/js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt index b19357d67a5..dd3db72c856 100644 --- a/js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt +++ b/js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1159 package foo diff --git a/libraries/stdlib/js/irRuntime/Enum.kt b/libraries/stdlib/js/irRuntime/Enum.kt new file mode 100644 index 00000000000..f58405e9a29 --- /dev/null +++ b/libraries/stdlib/js/irRuntime/Enum.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package kotlin + +public class Enum>(val name: String, val ordinal: Int) : Comparable> { + + override fun compareTo(other: Enum) = ordinal.compareTo(other.ordinal) + + override fun equals(other: Any?) = this === other + + override fun hashCode(): Int = identityHashCode(this) + + override fun toString() = name + + companion object +} \ No newline at end of file diff --git a/libraries/stdlib/js/irRuntime/core.kt b/libraries/stdlib/js/irRuntime/core.kt index 22b94afcebb..49c9c4420e3 100644 --- a/libraries/stdlib/js/irRuntime/core.kt +++ b/libraries/stdlib/js/irRuntime/core.kt @@ -102,3 +102,6 @@ fun hashCode(obj: dynamic): Int { """ ).unsafeCast() } + +// TODO: Use getObjectHashCode instead +fun identityHashCode(obj: dynamic): Int = hashCode(obj) \ No newline at end of file diff --git a/libraries/stdlib/js/irRuntime/exceptions.kt b/libraries/stdlib/js/irRuntime/exceptions.kt index 40523d7fae0..0b1e3fe53fd 100644 --- a/libraries/stdlib/js/irRuntime/exceptions.kt +++ b/libraries/stdlib/js/irRuntime/exceptions.kt @@ -61,6 +61,9 @@ open class NoSuchElementException(message: String?, cause: Throwable?) : Runtime } // TODO: fix function names to satisfy style convention (depends on built-in names) +fun THROW_ISE() { + throw IllegalStateException() +} fun THROW_CCE() { throw ClassCastException() }