From 85760770a8035d8e50d09ed17c614162f1e8e3ad Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 28 May 2020 11:20:16 +0300 Subject: [PATCH] [FIR2IR] Initialize built-in symbols at start of conversion --- compiler/fir/fir2ir/build.gradle.kts | 1 + .../src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt | 2 ++ compiler/testData/codegen/box/arrays/kt1291.kt | 1 - compiler/testData/codegen/box/builtinStubMethods/Iterator.kt | 1 - .../codegen/box/builtinStubMethods/IteratorWithRemove.kt | 1 - compiler/testData/codegen/box/builtinStubMethods/List.kt | 1 - .../testData/codegen/box/builtinStubMethods/ListIterator.kt | 1 - .../box/builtinStubMethods/ListWithAllImplementations.kt | 1 - .../builtinStubMethods/ListWithAllInheritedImplementations.kt | 1 - compiler/testData/codegen/box/builtinStubMethods/Map.kt | 1 - compiler/testData/codegen/box/builtinStubMethods/MapEntry.kt | 1 - .../codegen/box/builtinStubMethods/MapEntryWithSetValue.kt | 1 - .../codegen/box/builtinStubMethods/MapWithAllImplementations.kt | 1 - .../testData/codegen/box/builtinStubMethods/abstractMember.kt | 1 - .../codegen/box/builtinStubMethods/customReadOnlyIterator.kt | 1 - .../codegen/box/builtinStubMethods/implementationInTrait.kt | 1 - .../codegen/box/builtinStubMethods/inheritedImplementations.kt | 1 - .../box/builtinStubMethods/manyTypeParametersWithUpperBounds.kt | 1 - .../codegen/box/builtinStubMethods/nonTrivialUpperBound.kt | 1 - .../codegen/box/casts/mutableCollections/weirdMutableCasts.kt | 1 - compiler/testData/codegen/box/collections/readOnlyList.kt | 1 - compiler/testData/codegen/box/collections/readOnlyMap.kt | 1 - .../forInSequenceWithIndexCheckSideEffects.kt | 1 - .../forInSequenceWithIndexNoElementVarCheckSideEffects.kt | 1 - .../forInSequenceWithIndexNoIndexVarCheckSideEffects.kt | 1 - .../box/coroutines/featureIntersection/tailrec/controlFlowIf.kt | 1 - .../coroutines/featureIntersection/tailrec/controlFlowWhen.kt | 1 - compiler/testData/codegen/box/functions/kt1038.kt | 1 - .../testData/codegen/box/inlineClasses/UIntArraySortExample.kt | 1 - compiler/testData/codegen/box/jdk/stream.kt | 1 - compiler/testData/codegen/box/objects/flist.kt | 1 - compiler/testData/codegen/box/ranges/forInCustomIterable.kt | 1 - compiler/testData/codegen/box/specialBuiltins/maps.kt | 1 - .../codegen/box/specialBuiltins/noSpecialBridgeInSuperClass.kt | 1 - 34 files changed, 3 insertions(+), 32 deletions(-) diff --git a/compiler/fir/fir2ir/build.gradle.kts b/compiler/fir/fir2ir/build.gradle.kts index 4605fa6403c..39f2e535769 100644 --- a/compiler/fir/fir2ir/build.gradle.kts +++ b/compiler/fir/fir2ir/build.gradle.kts @@ -10,6 +10,7 @@ dependencies { compileOnly(project(":compiler:fir:tree")) compileOnly(project(":compiler:ir.tree")) compileOnly(project(":compiler:ir.psi2ir")) + compileOnly(project(":compiler:ir.backend.common")) compileOnly(intellijCoreDep()) { includeJars("intellij-core") } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt index fdef7159224..427fe7dfd05 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.backend +import org.jetbrains.kotlin.backend.common.ir.BuiltinSymbolsBase import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* @@ -173,6 +174,7 @@ class Fir2IrConverter( constantValueGenerator.typeTranslator = typeTranslator typeTranslator.constantValueGenerator = constantValueGenerator val builtIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, symbolTable) + BuiltinSymbolsBase(builtIns, moduleDescriptor.builtIns, symbolTable) val sourceManager = PsiSourceManager() val components = Fir2IrComponentsStorage(session, scopeSession, symbolTable, builtIns) val declarationStorage = Fir2IrDeclarationStorage(components, moduleDescriptor) diff --git a/compiler/testData/codegen/box/arrays/kt1291.kt b/compiler/testData/codegen/box/arrays/kt1291.kt index 4fb581befa2..02b5fd89707 100644 --- a/compiler/testData/codegen/box/arrays/kt1291.kt +++ b/compiler/testData/codegen/box/arrays/kt1291.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR var result = 0 fun Iterator.foreach(action: (T) -> Unit) { diff --git a/compiler/testData/codegen/box/builtinStubMethods/Iterator.kt b/compiler/testData/codegen/box/builtinStubMethods/Iterator.kt index ce5bff68933..061a1f3a856 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/Iterator.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/Iterator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyIterator(val v: T): Iterator { diff --git a/compiler/testData/codegen/box/builtinStubMethods/IteratorWithRemove.kt b/compiler/testData/codegen/box/builtinStubMethods/IteratorWithRemove.kt index 337f1632f48..f50786395cb 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/IteratorWithRemove.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/IteratorWithRemove.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyIterator(val v: T): Iterator { diff --git a/compiler/testData/codegen/box/builtinStubMethods/List.kt b/compiler/testData/codegen/box/builtinStubMethods/List.kt index 965847dab48..4a64bf05265 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/List.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/List.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyList: List { diff --git a/compiler/testData/codegen/box/builtinStubMethods/ListIterator.kt b/compiler/testData/codegen/box/builtinStubMethods/ListIterator.kt index a9feafd2337..c3bd9a90ea8 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/ListIterator.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/ListIterator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyListIterator : ListIterator { diff --git a/compiler/testData/codegen/box/builtinStubMethods/ListWithAllImplementations.kt b/compiler/testData/codegen/box/builtinStubMethods/ListWithAllImplementations.kt index f379c10f8ea..8f5988e87df 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/ListWithAllImplementations.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/ListWithAllImplementations.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyList(val v: T): List { diff --git a/compiler/testData/codegen/box/builtinStubMethods/ListWithAllInheritedImplementations.kt b/compiler/testData/codegen/box/builtinStubMethods/ListWithAllInheritedImplementations.kt index a86176c6ecc..cb1af1b6572 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/ListWithAllInheritedImplementations.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/ListWithAllInheritedImplementations.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM open class Super(val v: T) { diff --git a/compiler/testData/codegen/box/builtinStubMethods/Map.kt b/compiler/testData/codegen/box/builtinStubMethods/Map.kt index 3797cf6a8c7..c0324984796 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/Map.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/Map.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyMap: Map { diff --git a/compiler/testData/codegen/box/builtinStubMethods/MapEntry.kt b/compiler/testData/codegen/box/builtinStubMethods/MapEntry.kt index 9b9fa93f8d0..8c315a34b8d 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/MapEntry.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/MapEntry.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyMapEntry: Map.Entry { diff --git a/compiler/testData/codegen/box/builtinStubMethods/MapEntryWithSetValue.kt b/compiler/testData/codegen/box/builtinStubMethods/MapEntryWithSetValue.kt index 6d81843f2a0..3a07189a15d 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/MapEntryWithSetValue.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/MapEntryWithSetValue.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyMapEntry: Map.Entry { diff --git a/compiler/testData/codegen/box/builtinStubMethods/MapWithAllImplementations.kt b/compiler/testData/codegen/box/builtinStubMethods/MapWithAllImplementations.kt index 7470226ac88..879e1f929e9 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/MapWithAllImplementations.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/MapWithAllImplementations.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyMap: Map { diff --git a/compiler/testData/codegen/box/builtinStubMethods/abstractMember.kt b/compiler/testData/codegen/box/builtinStubMethods/abstractMember.kt index 4095782b50a..edd310d0b78 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/abstractMember.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/abstractMember.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM abstract class A : Iterator { diff --git a/compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt b/compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt index 1bd76c27c05..2038e67cbb5 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A : Collection { override val size: Int get() = throw UnsupportedOperationException() diff --git a/compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt b/compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt index 3a32191d923..c1b21f6b745 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM interface Addable { diff --git a/compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt b/compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt index aede967e01f..fd9a690ffe6 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM open class SetStringImpl { diff --git a/compiler/testData/codegen/box/builtinStubMethods/manyTypeParametersWithUpperBounds.kt b/compiler/testData/codegen/box/builtinStubMethods/manyTypeParametersWithUpperBounds.kt index b1ed6dbc75c..f906f817cce 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/manyTypeParametersWithUpperBounds.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/manyTypeParametersWithUpperBounds.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/builtinStubMethods/nonTrivialUpperBound.kt b/compiler/testData/codegen/box/builtinStubMethods/nonTrivialUpperBound.kt index 2e06e0fe07b..543e683d48d 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/nonTrivialUpperBound.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/nonTrivialUpperBound.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM class MyIterator : Iterator { diff --git a/compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt b/compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt index 2c689516aa5..4957754b1c8 100644 --- a/compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt +++ b/compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR_ES6 // TODO: muted automatically, investigate should it be ran for JS or not diff --git a/compiler/testData/codegen/box/collections/readOnlyList.kt b/compiler/testData/codegen/box/collections/readOnlyList.kt index f08c7ef70bb..041ec52be0b 100644 --- a/compiler/testData/codegen/box/collections/readOnlyList.kt +++ b/compiler/testData/codegen/box/collections/readOnlyList.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: J.java diff --git a/compiler/testData/codegen/box/collections/readOnlyMap.kt b/compiler/testData/codegen/box/collections/readOnlyMap.kt index 2db1f5a9eb9..89fd8d60c90 100644 --- a/compiler/testData/codegen/box/collections/readOnlyMap.kt +++ b/compiler/testData/codegen/box/collections/readOnlyMap.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: J.java diff --git a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexCheckSideEffects.kt b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexCheckSideEffects.kt index 3ffe2e28019..86414b0c9e1 100644 --- a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexCheckSideEffects.kt +++ b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexCheckSideEffects.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoElementVarCheckSideEffects.kt b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoElementVarCheckSideEffects.kt index 38a449f3cec..efc54ca97f8 100644 --- a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoElementVarCheckSideEffects.kt +++ b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoElementVarCheckSideEffects.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVarCheckSideEffects.kt b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVarCheckSideEffects.kt index adaf0b41c96..fa421a95a44 100644 --- a/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVarCheckSideEffects.kt +++ b/compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVarCheckSideEffects.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowIf.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowIf.kt index 981c2c589b3..58b8f89974e 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowIf.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowIf.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowWhen.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowWhen.kt index 49cd525d2fe..334020019c7 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowWhen.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/controlFlowWhen.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/functions/kt1038.kt b/compiler/testData/codegen/box/functions/kt1038.kt index 8f778354aa9..36770408c78 100644 --- a/compiler/testData/codegen/box/functions/kt1038.kt +++ b/compiler/testData/codegen/box/functions/kt1038.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR //KT-1038 Cannot compile lazy iterators class YieldingIterator(val yieldingFunction : ()->T?) : Iterator diff --git a/compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt b/compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt index 90b343bd840..b3e9d72ba18 100644 --- a/compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt +++ b/compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // !LANGUAGE: +InlineClasses diff --git a/compiler/testData/codegen/box/jdk/stream.kt b/compiler/testData/codegen/box/jdk/stream.kt index 94185022038..874eadcc8a4 100644 --- a/compiler/testData/codegen/box/jdk/stream.kt +++ b/compiler/testData/codegen/box/jdk/stream.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/box/objects/flist.kt b/compiler/testData/codegen/box/objects/flist.kt index 28192d153ea..9da8a335ad7 100644 --- a/compiler/testData/codegen/box/objects/flist.kt +++ b/compiler/testData/codegen/box/objects/flist.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR public abstract class FList() { public abstract val head: T public abstract val tail: FList diff --git a/compiler/testData/codegen/box/ranges/forInCustomIterable.kt b/compiler/testData/codegen/box/ranges/forInCustomIterable.kt index 8d24cd3ab78..c31564a45ea 100644 --- a/compiler/testData/codegen/box/ranges/forInCustomIterable.kt +++ b/compiler/testData/codegen/box/ranges/forInCustomIterable.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME diff --git a/compiler/testData/codegen/box/specialBuiltins/maps.kt b/compiler/testData/codegen/box/specialBuiltins/maps.kt index 3c06f6fb3e3..e16c06cba11 100644 --- a/compiler/testData/codegen/box/specialBuiltins/maps.kt +++ b/compiler/testData/codegen/box/specialBuiltins/maps.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE class A : Map { diff --git a/compiler/testData/codegen/box/specialBuiltins/noSpecialBridgeInSuperClass.kt b/compiler/testData/codegen/box/specialBuiltins/noSpecialBridgeInSuperClass.kt index e8128d184a2..8857356fa06 100644 --- a/compiler/testData/codegen/box/specialBuiltins/noSpecialBridgeInSuperClass.kt +++ b/compiler/testData/codegen/box/specialBuiltins/noSpecialBridgeInSuperClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE var result = ""