FIR: Add test on delegated member with default param in overridden...

sensitive to the file processing order, therefore failing on the
current fir2ir at least with the new irBuiltIns
This commit is contained in:
Ilya Chernikov
2021-06-21 17:12:28 +02:00
committed by TeamCityServer
parent a2385b5edd
commit c9b6847d83
10 changed files with 68 additions and 8 deletions
@@ -13939,6 +13939,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@Test
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@Nested @Nested
@@ -0,0 +1,20 @@
// FILE: lib.kt
interface ResolutionScope {
fun getContributedDescriptors(s: String = "OK"): String
}
// processing deprecatedScopes.kt before scopes.kt should show that there is no problem in processing delegated members after fake overrides
// FILE: deprecatedScopes.kt
abstract class DeprecatedLexicalScope(a: LexicalScope) : LexicalScope by a
// FILE: scopes.kt
interface LexicalScope : ResolutionScope
// FILE: main.kt
class ScopeImpl : LexicalScope {
override fun getContributedDescriptors(s: String): String = s
}
class Impl : DeprecatedLexicalScope(ScopeImpl())
fun box(): String = Impl().getContributedDescriptors()
@@ -13939,6 +13939,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@Test
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@Nested @Nested
@@ -13939,6 +13939,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@Test
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@Nested @Nested
@@ -30,8 +30,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsIrModuleSeria
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.descriptors.IrBuiltInsOverDescriptors
import org.jetbrains.kotlin.ir.descriptors.IrFunctionFactory
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
@@ -206,6 +205,7 @@ abstract class AbstractKlibTextTestCase : CodegenTestCase() {
return klibDir.canonicalPath return klibDir.canonicalPath
} }
@OptIn(ObsoleteDescriptorBasedAPI::class)
protected fun deserializeModule(stdlib: KotlinLibrary, klib: KotlinLibrary): IrModuleFragment { protected fun deserializeModule(stdlib: KotlinLibrary, klib: KotlinLibrary): IrModuleFragment {
val signaturer = IdSignatureDescriptor(JsManglerDesc) val signaturer = IdSignatureDescriptor(JsManglerDesc)
@@ -215,10 +215,8 @@ abstract class AbstractKlibTextTestCase : CodegenTestCase() {
val symbolTable = SymbolTable(signaturer, IrFactoryImpl) val symbolTable = SymbolTable(signaturer, IrFactoryImpl)
val typeTranslator = val typeTranslator =
TypeTranslatorImpl(symbolTable, myEnvironment.configuration.languageVersionSettings, testDescriptor) TypeTranslatorImpl(symbolTable, myEnvironment.configuration.languageVersionSettings, testDescriptor)
val irBuiltIns = IrBuiltIns(testDescriptor.builtIns, typeTranslator, symbolTable) val irBuiltIns = IrBuiltInsOverDescriptors(testDescriptor.builtIns, typeTranslator, symbolTable)
val functionFactory = IrFunctionFactory(irBuiltIns, symbolTable) val irLinker = JsIrLinker(null, IrMessageLogger.None, irBuiltIns, symbolTable, null, null)
irBuiltIns.functionFactory = functionFactory
val irLinker = JsIrLinker(null, IrMessageLogger.None, irBuiltIns, symbolTable, functionFactory, null, null)
irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib) irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib)
val testModule = irLinker.deserializeIrModuleHeader(testDescriptor, klib, DeserializationStrategy.ALL) val testModule = irLinker.deserializeIrModuleHeader(testDescriptor, klib, DeserializationStrategy.ALL)
irLinker.init(null, emptyList()) irLinker.init(null, emptyList())
@@ -275,8 +273,7 @@ abstract class AbstractKlibTextTestCase : CodegenTestCase() {
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl, NameProvider.DEFAULT) val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl, NameProvider.DEFAULT)
val context = psi2Ir.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable) val context = psi2Ir.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable)
val irBuiltIns = context.irBuiltIns val irBuiltIns = context.irBuiltIns
val functionFactory = IrFunctionFactory(irBuiltIns, symbolTable) val irLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, null, null)
val irLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, functionFactory, null, null)
irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib) irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib)
return psi2Ir.generateModuleFragment(context, ktFiles, listOf(irLinker), emptyList(), expectActualSymbols) to bindingContext return psi2Ir.generateModuleFragment(context, ktFiles, listOf(irLinker), emptyList(), expectActualSymbols) to bindingContext
@@ -11348,6 +11348,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/deprecated") @TestMetadata("compiler/testData/codegen/box/deprecated")
@@ -10072,6 +10072,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/deprecated") @TestMetadata("compiler/testData/codegen/box/deprecated")
@@ -9478,6 +9478,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/deprecated") @TestMetadata("compiler/testData/codegen/box/deprecated")
@@ -9478,6 +9478,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/deprecated") @TestMetadata("compiler/testData/codegen/box/deprecated")
@@ -4466,6 +4466,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
public void testWithDefaultParameters() throws Exception { public void testWithDefaultParameters() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
} }
@TestMetadata("withDefaultsMultipleFilesOrder.kt")
public void testWithDefaultsMultipleFilesOrder() throws Exception {
runTest("compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/deprecated") @TestMetadata("compiler/testData/codegen/box/deprecated")