diff --git a/generators/build.gradle.kts b/generators/build.gradle.kts index e0aa62381a2..c86565000b4 100644 --- a/generators/build.gradle.kts +++ b/generators/build.gradle.kts @@ -23,6 +23,7 @@ fun extraSourceSet(name: String, extendMain: Boolean = true): Pair throw UnsupportedOperationException("Unknown ir operation \"$methodName\"") } } + +private fun getIrBuiltIns(): IrBuiltIns { + val builtIns = DefaultBuiltIns.Instance + val languageSettings = LanguageVersionSettingsImpl(LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3) + + val moduleDescriptor = ModuleDescriptorImpl(Name.special(""), LockBasedStorageManager(""), builtIns) + val signaturer = object : IdSignatureComposer { + override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? = null + + override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? = null + } + val symbolTable = SymbolTable(signaturer) + val constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable) + val typeTranslator = TypeTranslator(symbolTable, languageSettings, builtIns) + constantValueGenerator.typeTranslator = typeTranslator + typeTranslator.constantValueGenerator = constantValueGenerator + + return IrBuiltIns(builtIns, typeTranslator, symbolTable) +} diff --git a/generators/tests/org/jetbrains/kotlin/generators/evaluate/GenerateBuiltInsMapTest.kt b/generators/tests/org/jetbrains/kotlin/generators/evaluate/GenerateBuiltInsMapTest.kt deleted file mode 100644 index c9c641154f1..00000000000 --- a/generators/tests/org/jetbrains/kotlin/generators/evaluate/GenerateBuiltInsMapTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.generators.test.evaluate - -import junit.framework.TestCase -import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor -import org.jetbrains.kotlin.builtins.DefaultBuiltIns -import org.jetbrains.kotlin.config.ApiVersion -import org.jetbrains.kotlin.config.LanguageVersion -import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl -import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl -import org.jetbrains.kotlin.generators.evaluate.DESTINATION -import org.jetbrains.kotlin.generators.evaluate.generateMap -import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmManglerDesc -import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -import org.jetbrains.kotlin.ir.util.ConstantValueGenerator -import org.jetbrains.kotlin.ir.util.SymbolTable -import org.jetbrains.kotlin.ir.util.TypeTranslator -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.storage.LockBasedStorageManager -import org.jetbrains.kotlin.test.KotlinTestUtils - -class GenerateBuiltInsMapTest : TestCase() { - fun testGeneratedDataIsUpToDate() { - val text = generateMap(getIrBuiltIns()) - KotlinTestUtils.assertEqualsToFile(DESTINATION, text) - } - - private fun getIrBuiltIns(): IrBuiltIns { - val builtIns = DefaultBuiltIns.Instance - val languageSettings = LanguageVersionSettingsImpl(LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3) - - val moduleDescriptor = ModuleDescriptorImpl(Name.special(""), LockBasedStorageManager(""), builtIns) - val mangler = JvmManglerDesc() - val signaturer = JvmIdSignatureDescriptor(mangler) - val symbolTable = SymbolTable(signaturer) - val constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable) - val typeTranslator = TypeTranslator(symbolTable, languageSettings, builtIns) - constantValueGenerator.typeTranslator = typeTranslator - typeTranslator.constantValueGenerator = constantValueGenerator - - return IrBuiltIns(builtIns, typeTranslator, symbolTable) - } -} diff --git a/generators/tests/org/jetbrains/kotlin/generators/interpreter/GenerateInterpreterMapTest.kt b/generators/tests/org/jetbrains/kotlin/generators/interpreter/GenerateInterpreterMapTest.kt new file mode 100644 index 00000000000..e4b64047aee --- /dev/null +++ b/generators/tests/org/jetbrains/kotlin/generators/interpreter/GenerateInterpreterMapTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.generators.test.interpreter + +import junit.framework.TestCase +import org.jetbrains.kotlin.generators.interpreter.DESTINATION +import org.jetbrains.kotlin.generators.interpreter.generateMap +import org.jetbrains.kotlin.test.KotlinTestUtils + +class GenerateBuiltInsMapTest : TestCase() { + fun testGeneratedDataIsUpToDate() { + val text = generateMap() + KotlinTestUtils.assertEqualsToFile(DESTINATION, text) + } +}