[K2, MPP] implement IR errors reporting and test infrastructure

Fix test data

^KT-56344 Fixed
This commit is contained in:
Ilya Chernikov
2023-02-09 12:34:30 +01:00
committed by Space Team
parent 3b1071b42b
commit 59b88f33b2
48 changed files with 2583 additions and 2146 deletions
@@ -493,7 +493,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
) ?: return null ) ?: return null
// FIR2IR // FIR2IR
val irResult = transformFirToIr(moduleStructure, outputs) val irResult = transformFirToIr(moduleStructure, outputs, diagnosticsReporter)
// Serialize klib // Serialize klib
if (arguments.irProduceKlibDir || arguments.irProduceKlibFile) { if (arguments.irProduceKlibDir || arguments.irProduceKlibFile) {
@@ -17,9 +17,11 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.prepareJsSessions import org.jetbrains.kotlin.cli.common.prepareJsSessions
import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
import org.jetbrains.kotlin.diagnostics.impl.PendingDiagnosticsCollectorWithSuppress
import org.jetbrains.kotlin.fir.BinaryModuleData import org.jetbrains.kotlin.fir.BinaryModuleData
import org.jetbrains.kotlin.fir.DependencyListForCliModule import org.jetbrains.kotlin.fir.DependencyListForCliModule
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
@@ -99,7 +101,8 @@ fun compileModuleToAnalyzedFir(
fun transformFirToIr( fun transformFirToIr(
moduleStructure: ModulesStructure, moduleStructure: ModulesStructure,
firOutputs: List<ModuleCompilerAnalyzedOutput> firOutputs: List<ModuleCompilerAnalyzedOutput>,
diagnosticsReporter: PendingDiagnosticsCollectorWithSuppress,
): Fir2IrResult { ): Fir2IrResult {
val fir2IrExtensions = Fir2IrExtensions.Default val fir2IrExtensions = Fir2IrExtensions.Default
@@ -135,6 +138,8 @@ fun transformFirToIr(
irMangler = JsManglerIr, irMangler = JsManglerIr,
visibilityConverter = Fir2IrVisibilityConverter.Default, visibilityConverter = Fir2IrVisibilityConverter.Default,
kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance, kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance,
diagnosticReporter = diagnosticsReporter,
languageVersionSettings = moduleStructure.compilerConfiguration.languageVersionSettings,
fir2IrResultPostCompute = { fir2IrResultPostCompute = {
(this.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors } (this.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors }
} }
@@ -156,7 +156,9 @@ object FirKotlinToJvmBytecodeCompiler {
val fir2IrResult = firResult.convertToIrAndActualizeForJvm( val fir2IrResult = firResult.convertToIrAndActualizeForJvm(
fir2IrExtensions, fir2IrExtensions,
irGenerationExtensions, irGenerationExtensions,
linkViaSignatures = moduleConfiguration.getBoolean(JVMConfigurationKeys.LINK_VIA_SIGNATURES) linkViaSignatures = moduleConfiguration.getBoolean(JVMConfigurationKeys.LINK_VIA_SIGNATURES),
diagnosticsReporter,
moduleConfiguration.languageVersionSettings
) )
performanceManager?.notifyIRTranslationFinished() performanceManager?.notifyIRTranslationFinished()
@@ -232,7 +232,10 @@ fun convertAnalyzedFirToIr(
} ?: emptyList() } ?: emptyList()
val linkViaSignatures = input.configuration.getBoolean(JVMConfigurationKeys.LINK_VIA_SIGNATURES) val linkViaSignatures = input.configuration.getBoolean(JVMConfigurationKeys.LINK_VIA_SIGNATURES)
val (irModuleFragment, components, pluginContext) = val (irModuleFragment, components, pluginContext) =
analysisResults.convertToIrAndActualizeForJvm(extensions, irGenerationExtensions, linkViaSignatures) analysisResults.convertToIrAndActualizeForJvm(
extensions, irGenerationExtensions, linkViaSignatures,
environment.diagnosticsReporter, input.configuration.languageVersionSettings
)
return ModuleCompilerIrBackendInput( return ModuleCompilerIrBackendInput(
input.targetId, input.targetId,
@@ -0,0 +1,747 @@
/*
* Copyright 2010-2023 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.test.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform")
@TestDataPath("$PROJECT_ROOT")
public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends AbstractFirLightTreeWithActualizerDiagnosticsTest {
@Test
public void testAllFilesPresentInMultiplatform() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectDataObject.kt")
public void testExpectDataObject() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectDataObject.kt");
}
@Test
@TestMetadata("expectInterfaceApplicability.kt")
public void testExpectInterfaceApplicability() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectInterfaceApplicability.kt");
}
@Test
@TestMetadata("expectObjectWithAbstractMember.kt")
public void testExpectObjectWithAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectObjectWithAbstractMember.kt");
}
@Test
@TestMetadata("headerFunInNonHeaderClass.kt")
public void testHeaderFunInNonHeaderClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerFunInNonHeaderClass.kt");
}
@Test
@TestMetadata("implDelegatedMember.kt")
public void testImplDelegatedMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt");
}
@Test
@TestMetadata("implDynamic.kt")
public void testImplDynamic() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implDynamic.kt");
}
@Test
@TestMetadata("implFakeOverride.kt")
public void testImplFakeOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implFakeOverride.kt");
}
@Test
@TestMetadata("incDecOperatorsInExpectClass.kt")
public void testIncDecOperatorsInExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/incDecOperatorsInExpectClass.kt");
}
@Test
@TestMetadata("incompatibles.kt")
public void testIncompatibles() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/incompatibles.kt");
}
@Test
@TestMetadata("kt54827.kt")
public void testKt54827() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/kt54827.kt");
}
@Test
@TestMetadata("modifierApplicability.kt")
public void testModifierApplicability() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/modifierApplicability.kt");
}
@Test
@TestMetadata("namedArguments.kt")
public void testNamedArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt");
}
@Test
@TestMetadata("privateTopLevelDeclarations.kt")
public void testPrivateTopLevelDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
}
@Test
@TestMetadata("sealedTypeAlias.kt")
public void testSealedTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.kt");
}
@Test
@TestMetadata("sealedTypeAliasTopLevel.kt")
public void testSealedTypeAliasTopLevel() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.kt");
}
@Test
@TestMetadata("smartcastOnMemberPropertyFromCommonClass.kt")
public void testSmartcastOnMemberPropertyFromCommonClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/smartcastOnMemberPropertyFromCommonClass.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
public class DefaultArguments {
@Test
public void testAllFilesPresentInDefaultArguments() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/defaultArguments"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("annotationArgumentEquality.kt")
public void testAnnotationArgumentEquality() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationArgumentEquality.kt");
}
@Test
@TestMetadata("annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotations.kt");
}
@Test
@TestMetadata("annotationsViaActualTypeAlias.kt")
public void testAnnotationsViaActualTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationsViaActualTypeAlias.kt");
}
@Test
@TestMetadata("annotationsViaActualTypeAlias2.kt")
public void testAnnotationsViaActualTypeAlias2() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationsViaActualTypeAlias2.kt");
}
@Test
@TestMetadata("constructor.kt")
public void testConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/constructor.kt");
}
@Test
@TestMetadata("expectedDeclaresDefaultArguments.kt")
public void testExpectedDeclaresDefaultArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedDeclaresDefaultArguments.kt");
}
@Test
@TestMetadata("expectedInheritsDefaultArguments.kt")
public void testExpectedInheritsDefaultArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedInheritsDefaultArguments.kt");
}
@Test
@TestMetadata("expectedVsNonExpectedWithDefaults.kt")
public void testExpectedVsNonExpectedWithDefaults() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedVsNonExpectedWithDefaults.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecated")
@TestDataPath("$PROJECT_ROOT")
public class Deprecated {
@Test
public void testAllFilesPresentInDeprecated() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecated"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("header.kt")
public void testHeader() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/deprecated/header.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum")
@TestDataPath("$PROJECT_ROOT")
public class Enum {
@Test
@TestMetadata("additionalEntriesInImpl.kt")
public void testAdditionalEntriesInImpl() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/additionalEntriesInImpl.kt");
}
@Test
public void testAllFilesPresentInEnum() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/enum"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("constructorInHeaderEnum.kt")
public void testConstructorInHeaderEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt");
}
@Test
@TestMetadata("differentEntryOrder.kt")
public void testDifferentEntryOrder() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/differentEntryOrder.kt");
}
@Test
@TestMetadata("enumEntryWithBody.kt")
public void testEnumEntryWithBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/enumEntryWithBody.kt");
}
@Test
@TestMetadata("javaEnum.kt")
public void testJavaEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/javaEnum.kt");
}
@Test
@TestMetadata("simpleEnum.kt")
public void testSimpleEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/simpleEnum.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness")
@TestDataPath("$PROJECT_ROOT")
public class Exhaustiveness {
@Test
public void testAllFilesPresentInExhaustiveness() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("commonSealedWithPlatformInheritor.kt")
public void testCommonSealedWithPlatformInheritor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/commonSealedWithPlatformInheritor.kt");
}
@Test
@TestMetadata("expectEnum.kt")
public void testExpectEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectEnum.kt");
}
@Test
@TestMetadata("expectSealedClass.kt")
public void testExpectSealedClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedClass.kt");
}
@Test
@TestMetadata("expectSealedClassWithActualTypealias.kt")
public void testExpectSealedClassWithActualTypealias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedClassWithActualTypealias.kt");
}
@Test
@TestMetadata("expectSealedInterface.kt")
public void testExpectSealedInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedInterface.kt");
}
@Test
@TestMetadata("kt45796.kt")
public void testKt45796() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/kt45796.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/generic")
@TestDataPath("$PROJECT_ROOT")
public class Generic {
@Test
public void testAllFilesPresentInGeneric() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/generic"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("functionTypeParameterBounds.kt")
public void testFunctionTypeParameterBounds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/functionTypeParameterBounds.kt");
}
@Test
@TestMetadata("genericMemberBounds.kt")
public void testGenericMemberBounds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/genericMemberBounds.kt");
}
@Test
@TestMetadata("membersInGenericClass.kt")
public void testMembersInGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/membersInGenericClass.kt");
}
@Test
@TestMetadata("typeParameterBoundsDifferentOrderActualMissing.kt")
public void testTypeParameterBoundsDifferentOrderActualMissing() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/typeParameterBoundsDifferentOrderActualMissing.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass")
@TestDataPath("$PROJECT_ROOT")
public class HeaderClass {
@Test
@TestMetadata("actualClassWithDefaultValuesInAnnotationViaTypealias.kt")
public void testActualClassWithDefaultValuesInAnnotationViaTypealias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt");
}
@Test
@TestMetadata("actualClassWithDifferentConstructors.kt")
public void testActualClassWithDifferentConstructors() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDifferentConstructors.kt");
}
@Test
@TestMetadata("actualMissing.kt")
public void testActualMissing() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
}
@Test
public void testAllFilesPresentInHeaderClass() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/headerClass"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("baseExpectClassWithoutConstructor.kt")
public void testBaseExpectClassWithoutConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/baseExpectClassWithoutConstructor.kt");
}
@Test
@TestMetadata("classKinds.kt")
public void testClassKinds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/classKinds.kt");
}
@Test
@TestMetadata("dontOverrideMethodsFromInterfaceInCommonCode.kt")
public void testDontOverrideMethodsFromInterfaceInCommonCode() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/dontOverrideMethodsFromInterfaceInCommonCode.kt");
}
@Test
@TestMetadata("equalsOverrideInActualInterface.kt")
public void testEqualsOverrideInActualInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/equalsOverrideInActualInterface.kt");
}
@Test
@TestMetadata("expectClassWithExplicitAbstractMember.kt")
public void testExpectClassWithExplicitAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectClassWithExplicitAbstractMember.kt");
}
@Test
@TestMetadata("expectClassWithoutConstructor.kt")
public void testExpectClassWithoutConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectClassWithoutConstructor.kt");
}
@Test
@TestMetadata("expectDeclarationWithStrongIncompatibilities.kt")
public void testExpectDeclarationWithStrongIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithStrongIncompatibilities.kt");
}
@Test
@TestMetadata("expectDeclarationWithWeakIncompatibilities.kt")
public void testExpectDeclarationWithWeakIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.kt");
}
@Test
@TestMetadata("expectFinalActualOpen.kt")
public void testExpectFinalActualOpen() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectFinalActualOpen.kt");
}
@Test
@TestMetadata("explicitConstructorDelegation.kt")
public void testExplicitConstructorDelegation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.kt");
}
@Test
@TestMetadata("extendExpectedClassWithAbstractMember.kt")
public void testExtendExpectedClassWithAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.kt");
}
@Test
@TestMetadata("extendExpectedClassWithoutExplicitOverrideOfMethod.kt")
public void testExtendExpectedClassWithoutExplicitOverrideOfMethod() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithoutExplicitOverrideOfMethod.kt");
}
@Test
@TestMetadata("extraHeaderOnMembers.kt")
public void testExtraHeaderOnMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extraHeaderOnMembers.kt");
}
@Test
@TestMetadata("functionAndPropertyWithSameName.kt")
public void testFunctionAndPropertyWithSameName() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/functionAndPropertyWithSameName.kt");
}
@Test
@TestMetadata("genericClassImplTypeAlias.kt")
public void testGenericClassImplTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt");
}
@Test
@TestMetadata("headerClassMember.kt")
public void testHeaderClassMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassMember.kt");
}
@Test
@TestMetadata("headerClassWithFunctionBody.kt")
public void testHeaderClassWithFunctionBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.kt");
}
@Test
@TestMetadata("implDataClass.kt")
public void testImplDataClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/implDataClass.kt");
}
@Test
@TestMetadata("implOpenClass.kt")
public void testImplOpenClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/implOpenClass.kt");
}
@Test
@TestMetadata("inheritanceByDelegationInExpectClass.kt")
public void testInheritanceByDelegationInExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/inheritanceByDelegationInExpectClass.kt");
}
@Test
@TestMetadata("memberPropertyKinds.kt")
public void testMemberPropertyKinds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt");
}
@Test
@TestMetadata("modalityCheckForExplicitAndImplicitOverride.kt")
public void testModalityCheckForExplicitAndImplicitOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/modalityCheckForExplicitAndImplicitOverride.kt");
}
@Test
@TestMetadata("morePermissiveVisibilityOnActual.kt")
public void testMorePermissiveVisibilityOnActual() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/morePermissiveVisibilityOnActual.kt");
}
@Test
@TestMetadata("morePermissiveVisibilityOnActualViaTypeAlias.kt")
public void testMorePermissiveVisibilityOnActualViaTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/morePermissiveVisibilityOnActualViaTypeAlias.kt");
}
@Test
@TestMetadata("nestedClasses.kt")
public void testNestedClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClasses.kt");
}
@Test
@TestMetadata("nestedClassesWithErrors.kt")
public void testNestedClassesWithErrors() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClassesWithErrors.kt");
}
@Test
@TestMetadata("noImplKeywordOnMember.kt")
public void testNoImplKeywordOnMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt");
}
@Test
@TestMetadata("privateMembers.kt")
public void testPrivateMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/privateMembers.kt");
}
@Test
@TestMetadata("simpleHeaderClass.kt")
public void testSimpleHeaderClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/simpleHeaderClass.kt");
}
@Test
@TestMetadata("smartCastOnExpectClass.kt")
public void testSmartCastOnExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/smartCastOnExpectClass.kt");
}
@Test
@TestMetadata("superClass.kt")
public void testSuperClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp")
@TestDataPath("$PROJECT_ROOT")
public class Hmpp {
@Test
public void testAllFilesPresentInHmpp() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("kt-55570.kt")
public void testKt_55570() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/kt-55570.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/simple.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis")
@TestDataPath("$PROJECT_ROOT")
public class MultiplatformCompositeAnalysis {
@Test
public void testAllFilesPresentInMultiplatformCompositeAnalysis() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectAndActualInTheSameModule.kt")
public void testExpectAndActualInTheSameModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
}
@Test
@TestMetadata("expectAndActualInTheSameModuleIncompatibilities.kt")
public void testExpectAndActualInTheSameModuleIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModuleIncompatibilities.kt");
}
@Test
@TestMetadata("intermediateWithActualAndExpect.kt")
public void testIntermediateWithActualAndExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
public class InlineClasses {
@Test
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/inlineClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectActualInlineClass.kt")
public void testExpectActualInlineClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/expectActualInlineClass.kt");
}
@Test
@TestMetadata("jvmInlineExpectValueClass.kt")
public void testJvmInlineExpectValueClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/jvmInlineExpectValueClass.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/java")
@TestDataPath("$PROJECT_ROOT")
public class Java {
@Test
public void testAllFilesPresentInJava() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/java"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("flexibleTypes.kt")
public void testFlexibleTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/java/flexibleTypes.kt");
}
@Test
@TestMetadata("parameterNames.kt")
public void testParameterNames() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/java/parameterNames.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelFun {
@Test
public void testAllFilesPresentInTopLevelFun() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelFun"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("callHeaderFun.kt")
public void testCallHeaderFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/callHeaderFun.kt");
}
@Test
@TestMetadata("callableReferenceOnExpectFun.kt")
public void testCallableReferenceOnExpectFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/callableReferenceOnExpectFun.kt");
}
@Test
@TestMetadata("conflictingHeaderDeclarations.kt")
public void testConflictingHeaderDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt");
}
@Test
@TestMetadata("conflictingImplDeclarations.kt")
public void testConflictingImplDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.kt");
}
@Test
@TestMetadata("functionModifiers.kt")
public void testFunctionModifiers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/functionModifiers.kt");
}
@Test
@TestMetadata("headerAndImplInDIfferentPackages.kt")
public void testHeaderAndImplInDIfferentPackages() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerAndImplInDIfferentPackages.kt");
}
@Test
@TestMetadata("headerDeclarationWithBody.kt")
public void testHeaderDeclarationWithBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.kt");
}
@Test
@TestMetadata("headerWithoutImpl.kt")
public void testHeaderWithoutImpl() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerWithoutImpl.kt");
}
@Test
@TestMetadata("implDeclarationWithoutBody.kt")
public void testImplDeclarationWithoutBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/implDeclarationWithoutBody.kt");
}
@Test
@TestMetadata("implWithoutHeader.kt")
public void testImplWithoutHeader() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/implWithoutHeader.kt");
}
@Test
@TestMetadata("inlineFun.kt")
public void testInlineFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/inlineFun.kt");
}
@Test
@TestMetadata("simpleHeaderFun.kt")
public void testSimpleHeaderFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/simpleHeaderFun.kt");
}
@Test
@TestMetadata("valueParameterModifiers.kt")
public void testValueParameterModifiers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/valueParameterModifiers.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelProperty {
@Test
public void testAllFilesPresentInTopLevelProperty() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("differentKindsOfProperties.kt")
public void testDifferentKindsOfProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt");
}
@Test
@TestMetadata("simpleHeaderVar.kt")
public void testSimpleHeaderVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simpleHeaderVar.kt");
}
}
}
@@ -0,0 +1,747 @@
/*
* Copyright 2010-2023 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.test.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform")
@TestDataPath("$PROJECT_ROOT")
public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFirPsiWithActualizerDiagnosticsTest {
@Test
public void testAllFilesPresentInMultiplatform() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectDataObject.kt")
public void testExpectDataObject() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectDataObject.kt");
}
@Test
@TestMetadata("expectInterfaceApplicability.kt")
public void testExpectInterfaceApplicability() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectInterfaceApplicability.kt");
}
@Test
@TestMetadata("expectObjectWithAbstractMember.kt")
public void testExpectObjectWithAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/expectObjectWithAbstractMember.kt");
}
@Test
@TestMetadata("headerFunInNonHeaderClass.kt")
public void testHeaderFunInNonHeaderClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerFunInNonHeaderClass.kt");
}
@Test
@TestMetadata("implDelegatedMember.kt")
public void testImplDelegatedMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt");
}
@Test
@TestMetadata("implDynamic.kt")
public void testImplDynamic() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implDynamic.kt");
}
@Test
@TestMetadata("implFakeOverride.kt")
public void testImplFakeOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/implFakeOverride.kt");
}
@Test
@TestMetadata("incDecOperatorsInExpectClass.kt")
public void testIncDecOperatorsInExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/incDecOperatorsInExpectClass.kt");
}
@Test
@TestMetadata("incompatibles.kt")
public void testIncompatibles() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/incompatibles.kt");
}
@Test
@TestMetadata("kt54827.kt")
public void testKt54827() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/kt54827.kt");
}
@Test
@TestMetadata("modifierApplicability.kt")
public void testModifierApplicability() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/modifierApplicability.kt");
}
@Test
@TestMetadata("namedArguments.kt")
public void testNamedArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt");
}
@Test
@TestMetadata("privateTopLevelDeclarations.kt")
public void testPrivateTopLevelDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
}
@Test
@TestMetadata("sealedTypeAlias.kt")
public void testSealedTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.kt");
}
@Test
@TestMetadata("sealedTypeAliasTopLevel.kt")
public void testSealedTypeAliasTopLevel() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.kt");
}
@Test
@TestMetadata("smartcastOnMemberPropertyFromCommonClass.kt")
public void testSmartcastOnMemberPropertyFromCommonClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/smartcastOnMemberPropertyFromCommonClass.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
public class DefaultArguments {
@Test
public void testAllFilesPresentInDefaultArguments() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/defaultArguments"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("annotationArgumentEquality.kt")
public void testAnnotationArgumentEquality() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationArgumentEquality.kt");
}
@Test
@TestMetadata("annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotations.kt");
}
@Test
@TestMetadata("annotationsViaActualTypeAlias.kt")
public void testAnnotationsViaActualTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationsViaActualTypeAlias.kt");
}
@Test
@TestMetadata("annotationsViaActualTypeAlias2.kt")
public void testAnnotationsViaActualTypeAlias2() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/annotationsViaActualTypeAlias2.kt");
}
@Test
@TestMetadata("constructor.kt")
public void testConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/constructor.kt");
}
@Test
@TestMetadata("expectedDeclaresDefaultArguments.kt")
public void testExpectedDeclaresDefaultArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedDeclaresDefaultArguments.kt");
}
@Test
@TestMetadata("expectedInheritsDefaultArguments.kt")
public void testExpectedInheritsDefaultArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedInheritsDefaultArguments.kt");
}
@Test
@TestMetadata("expectedVsNonExpectedWithDefaults.kt")
public void testExpectedVsNonExpectedWithDefaults() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/defaultArguments/expectedVsNonExpectedWithDefaults.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecated")
@TestDataPath("$PROJECT_ROOT")
public class Deprecated {
@Test
public void testAllFilesPresentInDeprecated() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecated"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("header.kt")
public void testHeader() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/deprecated/header.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum")
@TestDataPath("$PROJECT_ROOT")
public class Enum {
@Test
@TestMetadata("additionalEntriesInImpl.kt")
public void testAdditionalEntriesInImpl() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/additionalEntriesInImpl.kt");
}
@Test
public void testAllFilesPresentInEnum() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/enum"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("constructorInHeaderEnum.kt")
public void testConstructorInHeaderEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt");
}
@Test
@TestMetadata("differentEntryOrder.kt")
public void testDifferentEntryOrder() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/differentEntryOrder.kt");
}
@Test
@TestMetadata("enumEntryWithBody.kt")
public void testEnumEntryWithBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/enumEntryWithBody.kt");
}
@Test
@TestMetadata("javaEnum.kt")
public void testJavaEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/javaEnum.kt");
}
@Test
@TestMetadata("simpleEnum.kt")
public void testSimpleEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/enum/simpleEnum.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness")
@TestDataPath("$PROJECT_ROOT")
public class Exhaustiveness {
@Test
public void testAllFilesPresentInExhaustiveness() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("commonSealedWithPlatformInheritor.kt")
public void testCommonSealedWithPlatformInheritor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/commonSealedWithPlatformInheritor.kt");
}
@Test
@TestMetadata("expectEnum.kt")
public void testExpectEnum() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectEnum.kt");
}
@Test
@TestMetadata("expectSealedClass.kt")
public void testExpectSealedClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedClass.kt");
}
@Test
@TestMetadata("expectSealedClassWithActualTypealias.kt")
public void testExpectSealedClassWithActualTypealias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedClassWithActualTypealias.kt");
}
@Test
@TestMetadata("expectSealedInterface.kt")
public void testExpectSealedInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/expectSealedInterface.kt");
}
@Test
@TestMetadata("kt45796.kt")
public void testKt45796() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/exhaustiveness/kt45796.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/generic")
@TestDataPath("$PROJECT_ROOT")
public class Generic {
@Test
public void testAllFilesPresentInGeneric() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/generic"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("functionTypeParameterBounds.kt")
public void testFunctionTypeParameterBounds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/functionTypeParameterBounds.kt");
}
@Test
@TestMetadata("genericMemberBounds.kt")
public void testGenericMemberBounds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/genericMemberBounds.kt");
}
@Test
@TestMetadata("membersInGenericClass.kt")
public void testMembersInGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/membersInGenericClass.kt");
}
@Test
@TestMetadata("typeParameterBoundsDifferentOrderActualMissing.kt")
public void testTypeParameterBoundsDifferentOrderActualMissing() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/generic/typeParameterBoundsDifferentOrderActualMissing.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass")
@TestDataPath("$PROJECT_ROOT")
public class HeaderClass {
@Test
@TestMetadata("actualClassWithDefaultValuesInAnnotationViaTypealias.kt")
public void testActualClassWithDefaultValuesInAnnotationViaTypealias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt");
}
@Test
@TestMetadata("actualClassWithDifferentConstructors.kt")
public void testActualClassWithDifferentConstructors() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDifferentConstructors.kt");
}
@Test
@TestMetadata("actualMissing.kt")
public void testActualMissing() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
}
@Test
public void testAllFilesPresentInHeaderClass() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/headerClass"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("baseExpectClassWithoutConstructor.kt")
public void testBaseExpectClassWithoutConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/baseExpectClassWithoutConstructor.kt");
}
@Test
@TestMetadata("classKinds.kt")
public void testClassKinds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/classKinds.kt");
}
@Test
@TestMetadata("dontOverrideMethodsFromInterfaceInCommonCode.kt")
public void testDontOverrideMethodsFromInterfaceInCommonCode() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/dontOverrideMethodsFromInterfaceInCommonCode.kt");
}
@Test
@TestMetadata("equalsOverrideInActualInterface.kt")
public void testEqualsOverrideInActualInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/equalsOverrideInActualInterface.kt");
}
@Test
@TestMetadata("expectClassWithExplicitAbstractMember.kt")
public void testExpectClassWithExplicitAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectClassWithExplicitAbstractMember.kt");
}
@Test
@TestMetadata("expectClassWithoutConstructor.kt")
public void testExpectClassWithoutConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectClassWithoutConstructor.kt");
}
@Test
@TestMetadata("expectDeclarationWithStrongIncompatibilities.kt")
public void testExpectDeclarationWithStrongIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithStrongIncompatibilities.kt");
}
@Test
@TestMetadata("expectDeclarationWithWeakIncompatibilities.kt")
public void testExpectDeclarationWithWeakIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.kt");
}
@Test
@TestMetadata("expectFinalActualOpen.kt")
public void testExpectFinalActualOpen() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/expectFinalActualOpen.kt");
}
@Test
@TestMetadata("explicitConstructorDelegation.kt")
public void testExplicitConstructorDelegation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.kt");
}
@Test
@TestMetadata("extendExpectedClassWithAbstractMember.kt")
public void testExtendExpectedClassWithAbstractMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.kt");
}
@Test
@TestMetadata("extendExpectedClassWithoutExplicitOverrideOfMethod.kt")
public void testExtendExpectedClassWithoutExplicitOverrideOfMethod() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithoutExplicitOverrideOfMethod.kt");
}
@Test
@TestMetadata("extraHeaderOnMembers.kt")
public void testExtraHeaderOnMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/extraHeaderOnMembers.kt");
}
@Test
@TestMetadata("functionAndPropertyWithSameName.kt")
public void testFunctionAndPropertyWithSameName() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/functionAndPropertyWithSameName.kt");
}
@Test
@TestMetadata("genericClassImplTypeAlias.kt")
public void testGenericClassImplTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt");
}
@Test
@TestMetadata("headerClassMember.kt")
public void testHeaderClassMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassMember.kt");
}
@Test
@TestMetadata("headerClassWithFunctionBody.kt")
public void testHeaderClassWithFunctionBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.kt");
}
@Test
@TestMetadata("implDataClass.kt")
public void testImplDataClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/implDataClass.kt");
}
@Test
@TestMetadata("implOpenClass.kt")
public void testImplOpenClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/implOpenClass.kt");
}
@Test
@TestMetadata("inheritanceByDelegationInExpectClass.kt")
public void testInheritanceByDelegationInExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/inheritanceByDelegationInExpectClass.kt");
}
@Test
@TestMetadata("memberPropertyKinds.kt")
public void testMemberPropertyKinds() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt");
}
@Test
@TestMetadata("modalityCheckForExplicitAndImplicitOverride.kt")
public void testModalityCheckForExplicitAndImplicitOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/modalityCheckForExplicitAndImplicitOverride.kt");
}
@Test
@TestMetadata("morePermissiveVisibilityOnActual.kt")
public void testMorePermissiveVisibilityOnActual() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/morePermissiveVisibilityOnActual.kt");
}
@Test
@TestMetadata("morePermissiveVisibilityOnActualViaTypeAlias.kt")
public void testMorePermissiveVisibilityOnActualViaTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/morePermissiveVisibilityOnActualViaTypeAlias.kt");
}
@Test
@TestMetadata("nestedClasses.kt")
public void testNestedClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClasses.kt");
}
@Test
@TestMetadata("nestedClassesWithErrors.kt")
public void testNestedClassesWithErrors() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClassesWithErrors.kt");
}
@Test
@TestMetadata("noImplKeywordOnMember.kt")
public void testNoImplKeywordOnMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt");
}
@Test
@TestMetadata("privateMembers.kt")
public void testPrivateMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/privateMembers.kt");
}
@Test
@TestMetadata("simpleHeaderClass.kt")
public void testSimpleHeaderClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/simpleHeaderClass.kt");
}
@Test
@TestMetadata("smartCastOnExpectClass.kt")
public void testSmartCastOnExpectClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/smartCastOnExpectClass.kt");
}
@Test
@TestMetadata("superClass.kt")
public void testSuperClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp")
@TestDataPath("$PROJECT_ROOT")
public class Hmpp {
@Test
public void testAllFilesPresentInHmpp() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("kt-55570.kt")
public void testKt_55570() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/kt-55570.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/simple.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis")
@TestDataPath("$PROJECT_ROOT")
public class MultiplatformCompositeAnalysis {
@Test
public void testAllFilesPresentInMultiplatformCompositeAnalysis() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectAndActualInTheSameModule.kt")
public void testExpectAndActualInTheSameModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
}
@Test
@TestMetadata("expectAndActualInTheSameModuleIncompatibilities.kt")
public void testExpectAndActualInTheSameModuleIncompatibilities() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModuleIncompatibilities.kt");
}
@Test
@TestMetadata("intermediateWithActualAndExpect.kt")
public void testIntermediateWithActualAndExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
public class InlineClasses {
@Test
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/inlineClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("expectActualInlineClass.kt")
public void testExpectActualInlineClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/expectActualInlineClass.kt");
}
@Test
@TestMetadata("jvmInlineExpectValueClass.kt")
public void testJvmInlineExpectValueClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/jvmInlineExpectValueClass.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/java")
@TestDataPath("$PROJECT_ROOT")
public class Java {
@Test
public void testAllFilesPresentInJava() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/java"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("flexibleTypes.kt")
public void testFlexibleTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/java/flexibleTypes.kt");
}
@Test
@TestMetadata("parameterNames.kt")
public void testParameterNames() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/java/parameterNames.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelFun {
@Test
public void testAllFilesPresentInTopLevelFun() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelFun"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("callHeaderFun.kt")
public void testCallHeaderFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/callHeaderFun.kt");
}
@Test
@TestMetadata("callableReferenceOnExpectFun.kt")
public void testCallableReferenceOnExpectFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/callableReferenceOnExpectFun.kt");
}
@Test
@TestMetadata("conflictingHeaderDeclarations.kt")
public void testConflictingHeaderDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt");
}
@Test
@TestMetadata("conflictingImplDeclarations.kt")
public void testConflictingImplDeclarations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.kt");
}
@Test
@TestMetadata("functionModifiers.kt")
public void testFunctionModifiers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/functionModifiers.kt");
}
@Test
@TestMetadata("headerAndImplInDIfferentPackages.kt")
public void testHeaderAndImplInDIfferentPackages() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerAndImplInDIfferentPackages.kt");
}
@Test
@TestMetadata("headerDeclarationWithBody.kt")
public void testHeaderDeclarationWithBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.kt");
}
@Test
@TestMetadata("headerWithoutImpl.kt")
public void testHeaderWithoutImpl() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerWithoutImpl.kt");
}
@Test
@TestMetadata("implDeclarationWithoutBody.kt")
public void testImplDeclarationWithoutBody() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/implDeclarationWithoutBody.kt");
}
@Test
@TestMetadata("implWithoutHeader.kt")
public void testImplWithoutHeader() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/implWithoutHeader.kt");
}
@Test
@TestMetadata("inlineFun.kt")
public void testInlineFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/inlineFun.kt");
}
@Test
@TestMetadata("simpleHeaderFun.kt")
public void testSimpleHeaderFun() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/simpleHeaderFun.kt");
}
@Test
@TestMetadata("valueParameterModifiers.kt")
public void testValueParameterModifiers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/valueParameterModifiers.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelProperty {
@Test
public void testAllFilesPresentInTopLevelProperty() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("differentKindsOfProperties.kt")
public void testDifferentKindsOfProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt");
}
@Test
@TestMetadata("simpleHeaderVar.kt")
public void testSimpleHeaderVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simpleHeaderVar.kt");
}
}
}
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor
import org.jetbrains.kotlin.builtins.DefaultBuiltIns import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.backend.jvm.Fir2IrJvmSpecialAnnotationSymbolProvider import org.jetbrains.kotlin.fir.backend.jvm.Fir2IrJvmSpecialAnnotationSymbolProvider
@@ -36,6 +38,8 @@ fun FirResult.convertToIrAndActualizeForJvm(
fir2IrExtensions: Fir2IrExtensions, fir2IrExtensions: Fir2IrExtensions,
irGeneratorExtensions: Collection<IrGenerationExtension>, irGeneratorExtensions: Collection<IrGenerationExtension>,
linkViaSignatures: Boolean, linkViaSignatures: Boolean,
diagnosticReporter: DiagnosticReporter,
languageVersionSettings: LanguageVersionSettings,
): Fir2IrResult = this.convertToIrAndActualize( ): Fir2IrResult = this.convertToIrAndActualize(
fir2IrExtensions, fir2IrExtensions,
irGeneratorExtensions, irGeneratorExtensions,
@@ -43,6 +47,8 @@ fun FirResult.convertToIrAndActualizeForJvm(
signatureComposerCreator = { JvmIdSignatureDescriptor(JvmDescriptorMangler(null)) }, signatureComposerCreator = { JvmIdSignatureDescriptor(JvmDescriptorMangler(null)) },
irMangler = JvmIrMangler, irMangler = JvmIrMangler,
visibilityConverter = FirJvmVisibilityConverter, visibilityConverter = FirJvmVisibilityConverter,
diagnosticReporter = diagnosticReporter,
languageVersionSettings = languageVersionSettings,
kotlinBuiltIns = DefaultBuiltIns.Instance, kotlinBuiltIns = DefaultBuiltIns.Instance,
) )
@@ -54,6 +60,8 @@ fun FirResult.convertToIrAndActualize(
irMangler: KotlinMangler.IrMangler, irMangler: KotlinMangler.IrMangler,
visibilityConverter: Fir2IrVisibilityConverter, visibilityConverter: Fir2IrVisibilityConverter,
kotlinBuiltIns: KotlinBuiltIns, kotlinBuiltIns: KotlinBuiltIns,
diagnosticReporter: DiagnosticReporter,
languageVersionSettings: LanguageVersionSettings,
fir2IrResultPostCompute: Fir2IrResult.() -> Unit = {}, fir2IrResultPostCompute: Fir2IrResult.() -> Unit = {},
): Fir2IrResult { ): Fir2IrResult {
val result: Fir2IrResult val result: Fir2IrResult
@@ -111,9 +119,12 @@ fun FirResult.convertToIrAndActualize(
).also { ).also {
fir2IrResultPostCompute(it) fir2IrResultPostCompute(it)
} }
IrActualizer.actualize( IrActualizer.actualize(
result.irModuleFragment, result.irModuleFragment,
commonIrOutputs.map { it.irModuleFragment } commonIrOutputs.map { it.irModuleFragment },
diagnosticReporter,
languageVersionSettings
) )
} }
} }
@@ -275,7 +275,13 @@ class IncrementalFirJvmCompilerRunner(
val extensions = JvmFir2IrExtensions(configuration, JvmIrDeserializerImpl(), JvmIrMangler) val extensions = JvmFir2IrExtensions(configuration, JvmIrDeserializerImpl(), JvmIrMangler)
val irGenerationExtensions = val irGenerationExtensions =
(projectEnvironment as? VfsBasedProjectEnvironment)?.project?.let { IrGenerationExtension.getInstances(it) }.orEmpty() (projectEnvironment as? VfsBasedProjectEnvironment)?.project?.let { IrGenerationExtension.getInstances(it) }.orEmpty()
val platformIrOutput = cycleResult.convertToIrAndActualizeForJvm(extensions, irGenerationExtensions, linkViaSignatures = false) val platformIrOutput = cycleResult.convertToIrAndActualizeForJvm(
extensions,
irGenerationExtensions,
linkViaSignatures = false,
compilerEnvironment.diagnosticsReporter,
configuration.languageVersionSettings
)
performanceManager?.notifyIRTranslationFinished() performanceManager?.notifyIRTranslationFinished()
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2023 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.backend.common
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
import org.jetbrains.kotlin.diagnostics.error1
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers.STRING
import org.jetbrains.kotlin.diagnostics.rendering.Renderers.MODULE_WITH_PLATFORM
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
object CommonBackendErrors {
val NO_ACTUAL_FOR_EXPECT by error1<PsiElement, ModuleDescriptor>()
val MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED by error1<PsiElement, String>()
init {
RootDiagnosticRendererFactory.registerFactory(KtDefaultCommonBackendErrorMessages)
}
}
object KtDefaultCommonBackendErrorMessages : BaseDiagnosticRendererFactory() {
override val MAP = KtDiagnosticFactoryToRendererMap("KT").also { map ->
map.put(CommonBackendErrors.NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual declaration in module {1}", MODULE_WITH_PLATFORM)
map.put(CommonBackendErrors.MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED, "{0} must override {1} because it inherits multiple interface methods of it", STRING)
}
}
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.backend.common.actualizer package org.jetbrains.kotlin.backend.common.actualizer
import org.jetbrains.kotlin.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.backend.common.ir.isExpect import org.jetbrains.kotlin.backend.common.ir.isExpect
import org.jetbrains.kotlin.backend.common.ir.isProperExpect import org.jetbrains.kotlin.backend.common.ir.isProperExpect
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
@@ -18,7 +19,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
internal class ExpectActualCollector(private val mainFragment: IrModuleFragment, private val dependentFragments: List<IrModuleFragment>) { internal class ExpectActualCollector(
private val mainFragment: IrModuleFragment,
private val dependentFragments: List<IrModuleFragment>,
private val diagnosticsReporter: KtDiagnosticReporterWithImplicitIrBasedContext
) {
fun collect(): Pair<Map<IrSymbol, IrSymbol>, Map<FqName, FqName>> { fun collect(): Pair<Map<IrSymbol, IrSymbol>, Map<FqName, FqName>> {
val result = mutableMapOf<IrSymbol, IrSymbol>() val result = mutableMapOf<IrSymbol, IrSymbol>()
// Collect and link classifiers at first to make it possible to expand type aliases on the callables linking // Collect and link classifiers at first to make it possible to expand type aliases on the callables linking
@@ -38,7 +43,7 @@ internal class ExpectActualCollector(private val mainFragment: IrModuleFragment,
ActualClassifiersCollector(actualClassifiers, allActualDeclarations, typeAliasMap).visitModuleFragment(fragment, false) ActualClassifiersCollector(actualClassifiers, allActualDeclarations, typeAliasMap).visitModuleFragment(fragment, false)
} }
val linkCollector = ClassifiersLinkCollector(this, actualClassifiers) val linkCollector = ClassifiersLinkCollector(this, actualClassifiers, diagnosticsReporter)
dependentFragments.forEach { linkCollector.visitModuleFragment(it) } dependentFragments.forEach { linkCollector.visitModuleFragment(it) }
return allActualDeclarations to typeAliasMap return allActualDeclarations to typeAliasMap
@@ -51,7 +56,7 @@ internal class ExpectActualCollector(private val mainFragment: IrModuleFragment,
val actualMembers = mutableMapOf<String, IrDeclarationBase>() val actualMembers = mutableMapOf<String, IrDeclarationBase>()
collectActualCallables(this, actualMembers, allActualDeclarations) collectActualCallables(this, actualMembers, allActualDeclarations)
val collector = CallablesLinkCollector(this, actualMembers, typeAliasMap) val collector = CallablesLinkCollector(this, actualMembers, typeAliasMap, diagnosticsReporter)
dependentFragments.forEach { collector.visitModuleFragment(it) } dependentFragments.forEach { collector.visitModuleFragment(it) }
} }
} }
@@ -106,14 +111,15 @@ private class ActualClassifiersCollector(
private class ClassifiersLinkCollector( private class ClassifiersLinkCollector(
private val expectActualMap: MutableMap<IrSymbol, IrSymbol>, private val expectActualMap: MutableMap<IrSymbol, IrSymbol>,
private val actualClassifiers: Map<FqName, IrSymbol> private val actualClassifiers: Map<FqName, IrSymbol>,
private val diagnosticsReporter: KtDiagnosticReporterWithImplicitIrBasedContext
) : IrElementVisitorVoid { ) : IrElementVisitorVoid {
private fun addLinkOrReportMissing(expectElement: IrSymbolOwner, actualTypeId: FqName) { private fun addLinkOrReportMissing(expectElement: IrDeclaration, actualTypeId: FqName) {
val actualClassifier = actualClassifiers[actualTypeId] val actualClassifier = actualClassifiers[actualTypeId]
if (actualClassifier != null) { if (actualClassifier != null) {
expectActualMap[expectElement.symbol] = actualClassifier expectActualMap[expectElement.symbol] = actualClassifier
} else if (!expectElement.containsOptionalExpectation()) { } else if (!expectElement.containsOptionalExpectation()) {
reportMissingActual(expectElement) diagnosticsReporter.reportMissingActual(expectElement)
} }
} }
@@ -165,7 +171,8 @@ private fun collectActualCallables(
private class CallablesLinkCollector( private class CallablesLinkCollector(
private val expectActualMap: MutableMap<IrSymbol, IrSymbol>, private val expectActualMap: MutableMap<IrSymbol, IrSymbol>,
private val actualMembers: Map<String, IrDeclarationBase>, private val actualMembers: Map<String, IrDeclarationBase>,
private val typeAliasMap: Map<FqName, FqName> private val typeAliasMap: Map<FqName, FqName>,
private val diagnosticsReporter: KtDiagnosticReporterWithImplicitIrBasedContext
) : IrElementVisitorVoid { ) : IrElementVisitorVoid {
override fun visitFunction(declaration: IrFunction) = addLink(declaration) override fun visitFunction(declaration: IrFunction) = addLink(declaration)
@@ -182,7 +189,7 @@ private class CallablesLinkCollector(
declaration.setter?.symbol?.let { expectActualMap[it] = actualProperty.setter!!.symbol } declaration.setter?.symbol?.let { expectActualMap[it] = actualProperty.setter!!.symbol }
} }
} else if (!declaration.parent.containsOptionalExpectation()) { } else if (!declaration.parent.containsOptionalExpectation()) {
reportMissingActual(declaration) diagnosticsReporter.reportMissingActual(declaration)
} }
} }
@@ -5,17 +5,25 @@
package org.jetbrains.kotlin.backend.common.actualizer package org.jetbrains.kotlin.backend.common.actualizer
import org.jetbrains.kotlin.backend.common.ir.isProperExpect import org.jetbrains.kotlin.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
object IrActualizer { object IrActualizer {
fun actualize(mainFragment: IrModuleFragment, dependentFragments: List<IrModuleFragment>) { fun actualize(
val (expectActualMap, typeAliasMap) = ExpectActualCollector(mainFragment, dependentFragments).collect() mainFragment: IrModuleFragment,
dependentFragments: List<IrModuleFragment>,
diagnosticReporter: DiagnosticReporter,
languageVersionSettings: LanguageVersionSettings
) {
val ktDiagnosticReporter = KtDiagnosticReporterWithImplicitIrBasedContext(diagnosticReporter, languageVersionSettings)
val (expectActualMap, typeAliasMap) = ExpectActualCollector(mainFragment, dependentFragments, ktDiagnosticReporter).collect()
FunctionDefaultParametersActualizer(expectActualMap).actualize() FunctionDefaultParametersActualizer(expectActualMap).actualize()
removeExpectDeclarations(dependentFragments, expectActualMap) removeExpectDeclarations(dependentFragments, expectActualMap)
addMissingFakeOverrides(expectActualMap, dependentFragments, typeAliasMap) addMissingFakeOverrides(expectActualMap, dependentFragments, typeAliasMap, ktDiagnosticReporter)
linkExpectToActual(expectActualMap, dependentFragments) linkExpectToActual(expectActualMap, dependentFragments)
mergeIrFragments(mainFragment, dependentFragments) mergeIrFragments(mainFragment, dependentFragments)
} }
@@ -40,9 +48,10 @@ object IrActualizer {
private fun addMissingFakeOverrides( private fun addMissingFakeOverrides(
expectActualMap: Map<IrSymbol, IrSymbol>, expectActualMap: Map<IrSymbol, IrSymbol>,
dependentFragments: List<IrModuleFragment>, dependentFragments: List<IrModuleFragment>,
typeAliasMap: Map<FqName, FqName> typeAliasMap: Map<FqName, FqName>,
diagnosticsReporter: KtDiagnosticReporterWithImplicitIrBasedContext
) { ) {
MissingFakeOverridesAdder(expectActualMap, typeAliasMap).apply { dependentFragments.forEach { visitModuleFragment(it) } } MissingFakeOverridesAdder(expectActualMap, typeAliasMap, diagnosticsReporter).apply { dependentFragments.forEach { visitModuleFragment(it) } }
} }
private fun linkExpectToActual(expectActualMap: Map<IrSymbol, IrSymbol>, dependentFragments: List<IrModuleFragment>) { private fun linkExpectToActual(expectActualMap: Map<IrSymbol, IrSymbol>, dependentFragments: List<IrModuleFragment>) {
@@ -5,18 +5,18 @@
package org.jetbrains.kotlin.backend.common.actualizer package org.jetbrains.kotlin.backend.common.actualizer
import org.jetbrains.kotlin.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.backend.common.CommonBackendErrors
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.IrDeclarationBase import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrFail import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.util.hasAnnotation import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.kotlinFqName import org.jetbrains.kotlin.ir.util.kotlinFqName
import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.util.module
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.multiplatform.OptionalAnnotationUtil import org.jetbrains.kotlin.resolve.multiplatform.OptionalAnnotationUtil
@@ -71,14 +71,13 @@ private fun appendElementFullName(
} }
} }
fun reportMissingActual(irElement: IrElement) { @OptIn(ObsoleteDescriptorBasedAPI::class)
// TODO: setup diagnostics reporting fun KtDiagnosticReporterWithImplicitIrBasedContext.reportMissingActual(irDeclaration: IrDeclaration) {
throw AssertionError("Missing actual for ${irElement.render()}") at(irDeclaration).report(CommonBackendErrors.NO_ACTUAL_FOR_EXPECT, irDeclaration.module)
} }
fun reportManyInterfacesMembersNotImplemented(declaration: IrClass, actualMember: IrDeclarationWithName) { fun KtDiagnosticReporterWithImplicitIrBasedContext.reportManyInterfacesMembersNotImplemented(declaration: IrClass, actualMember: IrDeclarationWithName) {
// TODO: setup diagnostics reporting at(declaration).report(CommonBackendErrors.MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED, actualMember.name.asString())
throw AssertionError("${declaration.name} must override ${actualMember.name} because it inherits multiple interface methods of it")
} }
internal fun IrElement.containsOptionalExpectation(): Boolean { internal fun IrElement.containsOptionalExpectation(): Boolean {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.backend.common.actualizer package org.jetbrains.kotlin.backend.common.actualizer
import org.jetbrains.kotlin.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.builders.declarations.buildFun import org.jetbrains.kotlin.ir.builders.declarations.buildFun
import org.jetbrains.kotlin.ir.builders.declarations.buildProperty import org.jetbrains.kotlin.ir.builders.declarations.buildProperty
@@ -22,7 +23,8 @@ import org.jetbrains.kotlin.name.FqName
class MissingFakeOverridesAdder( class MissingFakeOverridesAdder(
private val expectActualMap: Map<IrSymbol, IrSymbol>, private val expectActualMap: Map<IrSymbol, IrSymbol>,
private val typeAliasMap: Map<FqName, FqName> private val typeAliasMap: Map<FqName, FqName>,
private val diagnosticsReporter: KtDiagnosticReporterWithImplicitIrBasedContext
) : IrElementVisitorVoid { ) : IrElementVisitorVoid {
override fun visitClass(declaration: IrClass) { override fun visitClass(declaration: IrClass) {
if (!declaration.isExpect) { if (!declaration.isExpect) {
@@ -75,7 +77,7 @@ class MissingFakeOverridesAdder(
is IrFunctionImpl, is IrFunctionImpl,
is IrPropertyImpl -> { is IrPropertyImpl -> {
if (members[generateIrElementFullName(actualMember, expectActualMap, typeAliasMap)] != null) { if (members[generateIrElementFullName(actualMember, expectActualMap, typeAliasMap)] != null) {
reportManyInterfacesMembersNotImplemented(declaration, actualMember as IrDeclarationWithName) diagnosticsReporter.reportManyInterfacesMembersNotImplemented(declaration, actualMember as IrDeclarationWithName)
return return
} }
@@ -0,0 +1,34 @@
// MODULE: m1-common
// FILE: common.kt
<!NO_ACTUAL_FOR_EXPECT{JVM}!>expect enum class Foo {
<!NO_ACTUAL_FOR_EXPECT{JVM}!>ENTRY<!>
}<!>
expect enum class _TimeUnit
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual typealias Foo = FooImpl
actual typealias _TimeUnit = java.util.concurrent.TimeUnit
// FILE: FooImpl.java
public enum FooImpl {
ENTRY("OK") {
@Override
public String getResult() {
return value;
}
};
protected final String value;
public FooImpl(String value) {
this.value = value;
}
public abstract String getResult();
}
@@ -1,6 +1,6 @@
// FIR_IDENTICAL
// MODULE: m1-common // MODULE: m1-common
// FILE: common.kt // FILE: common.kt
expect enum class Foo { expect enum class Foo {
ENTRY ENTRY
} }
@@ -9,11 +9,13 @@ expect enum class _TimeUnit
// MODULE: m2-jvm()()(m1-common) // MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt // FILE: jvm.kt
actual typealias Foo = FooImpl actual typealias Foo = FooImpl
actual typealias _TimeUnit = java.util.concurrent.TimeUnit actual typealias _TimeUnit = java.util.concurrent.TimeUnit
// FILE: FooImpl.java // FILE: FooImpl.java
public enum FooImpl { public enum FooImpl {
ENTRY("OK") { ENTRY("OK") {
@Override @Override
@@ -0,0 +1,17 @@
// MODULE: m1-common
// FILE: common.kt
<!NO_ACTUAL_FOR_EXPECT{JVM}!>expect enum class Foo {
ENTRY1,
ENTRY2,
ENTRY3;
}<!>
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual enum class Foo(val x: String) {
ENTRY1("1"),
ENTRY2("2"),
ENTRY3("3");
}
@@ -1,6 +1,6 @@
// FIR_IDENTICAL
// MODULE: m1-common // MODULE: m1-common
// FILE: common.kt // FILE: common.kt
expect enum class Foo { expect enum class Foo {
ENTRY1, ENTRY1,
ENTRY2, ENTRY2,
@@ -9,6 +9,7 @@ expect enum class Foo {
// MODULE: m2-jvm()()(m1-common) // MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt // FILE: jvm.kt
actual enum class Foo(val x: String) { actual enum class Foo(val x: String) {
ENTRY1("1"), ENTRY1("1"),
ENTRY2("2"), ENTRY2("2"),
@@ -6,8 +6,8 @@ expect annotation class Foo2
expect annotation class Foo3 expect annotation class Foo3
expect annotation class Foo4 expect annotation class Foo4
expect annotation class Foo5() expect annotation class Foo5()
expect annotation class Foo6() expect annotation class Foo6<!NO_ACTUAL_FOR_EXPECT{JVM}!>()<!>
expect annotation class Foo7() expect annotation class Foo7<!NO_ACTUAL_FOR_EXPECT{JVM}!>()<!>
@<!UNRESOLVED_REFERENCE!>Foo1<!> @<!UNRESOLVED_REFERENCE!>Foo1<!>
fun foo() {} fun foo() {}
@@ -5,9 +5,9 @@ expect class Foo1
expect class Foo2 expect class Foo2
expect class Foo3 expect class Foo3
expect class Bar1() expect class Bar1<!NO_ACTUAL_FOR_EXPECT{JVM}!>()<!>
expect class Bar2() expect class Bar2<!NO_ACTUAL_FOR_EXPECT{JVM}!>()<!>
expect class Bar3() expect class Bar3<!NO_ACTUAL_FOR_EXPECT{JVM}!>()<!>
expect class Bar4() expect class Bar4()
expect class Bar5() expect class Bar5()
expect class Bar6() expect class Bar6()
@@ -3,12 +3,12 @@
// FILE: common.kt // FILE: common.kt
expect fun foo1(x: Int) expect fun foo1(x: Int)
expect fun foo2(x: Int) <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun foo2(x: Int)<!>
expect class NoArgConstructor() expect class NoArgConstructor()
expect fun foo3(): Int expect fun foo3(): Int
expect fun foo4(): Int <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun foo4(): Int<!>
// MODULE: m2-jvm()()(m1-common) // MODULE: m2-jvm()()(m1-common)
@@ -15,7 +15,7 @@ expect class C {
} }
expect class D { expect class D {
class N <!NO_ACTUAL_FOR_EXPECT{JVM}!>class N<!>
} }
expect class E { expect class E {
@@ -2,7 +2,7 @@
// FILE: common.kt // FILE: common.kt
class Foo { class Foo {
<!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!><!WRONG_MODIFIER_TARGET!>expect<!> fun bar(): String<!> <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY, NO_ACTUAL_FOR_EXPECT{JVM}!><!WRONG_MODIFIER_TARGET!>expect<!> fun bar(): String<!>
} }
// MODULE: m1-jvm()()(m1-common) // MODULE: m1-jvm()()(m1-common)
@@ -1,11 +1,12 @@
// MODULE: common // MODULE: common
// TARGET_PLATFORM: Common // TARGET_PLATFORM: Common
expect class CommonClass {
fun memberFun() <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect class CommonClass {
val memberProp: Int <!NO_ACTUAL_FOR_EXPECT{JVM}!>fun memberFun()<!>
class Nested <!NO_ACTUAL_FOR_EXPECT{JVM}!>val memberProp: Int<!>
inner class Inner <!NO_ACTUAL_FOR_EXPECT{JVM}!>class Nested<!>
} <!NO_ACTUAL_FOR_EXPECT{JVM}!>inner class Inner<!>
}<!>
<!ACTUAL_WITHOUT_EXPECT!>actual class CommonClass { <!ACTUAL_WITHOUT_EXPECT!>actual class CommonClass {
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!> <!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!> <!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
@@ -13,15 +14,16 @@ expect class CommonClass {
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!> <!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
}<!> }<!>
expect fun commonFun() <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun commonFun()<!>
<!ACTUAL_WITHOUT_EXPECT!>actual fun commonFun() {}<!> <!ACTUAL_WITHOUT_EXPECT!>actual fun commonFun() {}<!>
expect val commonProperty: String <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect val commonProperty: String<!>
<!ACTUAL_WITHOUT_EXPECT!>actual val commonProperty: String <!ACTUAL_WITHOUT_EXPECT!>actual val commonProperty: String
get() = "hello"<!> get() = "hello"<!>
// MODULE: intermediate()()(common) // MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common // TARGET_PLATFORM: Common
expect class IntermediateClass { expect class IntermediateClass {
fun memberFun() fun memberFun()
val memberProp: Int val memberProp: Int
@@ -43,6 +45,7 @@ expect val intermediateProperty: String
get() = "hello"<!> get() = "hello"<!>
// MODULE: main()()(intermediate) // MODULE: main()()(intermediate)
expect class PlatformClass { expect class PlatformClass {
fun memberFun() fun memberFun()
val memberProp: Int val memberProp: Int
@@ -1,5 +1,6 @@
// MODULE: common // MODULE: common
// TARGET_PLATFORM: Common // TARGET_PLATFORM: Common
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> { expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> {
fun memberFun() fun memberFun()
val memberProp: Int val memberProp: Int
@@ -22,6 +23,7 @@ actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonProperty<!>: String
// MODULE: intermediate()()(common) // MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common // TARGET_PLATFORM: Common
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> { expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> {
fun memberFun() fun memberFun()
val memberProp: Int val memberProp: Int
@@ -43,6 +45,7 @@ actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateProperty<!>: Stri
get() = "hello" get() = "hello"
// MODULE: main()()(intermediate) // MODULE: main()()(intermediate)
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> { expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> {
fun memberFun() fun memberFun()
val memberProp: Int val memberProp: Int
@@ -4,7 +4,7 @@
expect fun parameterCount() expect fun parameterCount()
fun parameterCount(p: String) {} fun parameterCount(p: String) {}
expect fun parameterCount2() <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun parameterCount2()<!>
<!ACTUAL_WITHOUT_EXPECT!>actual fun parameterCount2(p: String) {}<!> <!ACTUAL_WITHOUT_EXPECT!>actual fun parameterCount2(p: String) {}<!>
expect fun callableKind(): Int expect fun callableKind(): Int
@@ -13,9 +13,9 @@ val callableKind: Int = 1
expect fun <T> typeParameterCount() expect fun <T> typeParameterCount()
fun typeParameterCount() {} fun typeParameterCount() {}
expect enum class EnumEntries { <!NO_ACTUAL_FOR_EXPECT{JVM}, NO_ACTUAL_FOR_EXPECT{JVM}, NO_ACTUAL_FOR_EXPECT{JVM}, NO_ACTUAL_FOR_EXPECT{JVM}!>expect enum class EnumEntries {
ONE, TWO; <!NO_ACTUAL_FOR_EXPECT{JVM}!>ONE,<!> <!NO_ACTUAL_FOR_EXPECT{JVM}!>TWO;<!>
} }<!>
<!ACTUAL_WITHOUT_EXPECT!>actual enum class EnumEntries { <!ACTUAL_WITHOUT_EXPECT!>actual enum class EnumEntries {
ONE; ONE;
}<!> }<!>
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNSUPPORTED
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
constructor(p: Any)
fun f1(s: String): Int
fun f2(s: List<String>?): MutableMap<Boolean?, Foo>
fun <T : Set<Number>> f3(t: T): T?
}
// MODULE: m2-js()()(m1-common)
// FILE: js.kt
// TODO: do not suppress UNSUPPORTED once JS files in multi-platform tests are analyzed with JS analyzer facade
actual class Foo {
actual constructor(p: dynamic) {}
actual fun f1(s: dynamic): dynamic = null!!
actual fun f2(s: dynamic): MutableMap<Boolean?, Foo> = null!!
actual fun <T : Set<Number>> f3(t: T): dynamic = null!!
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNSUPPORTED // !DIAGNOSTICS: -UNSUPPORTED
// MODULE: m1-common // MODULE: m1-common
// FILE: common.kt // FILE: common.kt
@@ -0,0 +1,31 @@
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
constructor(p: Any)
fun f1(s: String): Int
<!NO_ACTUAL_FOR_EXPECT{JVM}!>fun f2(s: List<String>?): MutableMap<Boolean?, Foo><!>
<!NO_ACTUAL_FOR_EXPECT{JVM}!>fun <T : Set<Number>> f3(t: T): T?<!>
}
// MODULE: m2-jvm()()(m1-common)
// FILE: FooImpl.java
import java.util.*;
public class FooImpl {
public FooImpl(Object p) {}
public final int f1(String s) { return 0; }
public final Map<Boolean, FooImpl> f2(List<String> s) { return null; }
public final <T extends Set<Number>> T f3(T t) { return null; }
}
// FILE: jvm.kt
actual typealias Foo = FooImpl
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// MODULE: m1-common // MODULE: m1-common
// FILE: common.kt // FILE: common.kt
@@ -0,0 +1,16 @@
// MODULE: m1-common
// FILE: common.kt
expect sealed class Presence {
<!NO_ACTUAL_FOR_EXPECT{JVM}!>object Online: Presence<!>
<!NO_ACTUAL_FOR_EXPECT{JVM}!>object Offline: Presence<!>
}
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual typealias Presence = P
sealed class P {
object Online : P()
object Offline : P()
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// MODULE: m1-common // MODULE: m1-common
// FILE: common.kt // FILE: common.kt
@@ -2,7 +2,7 @@
// FILE: common.kt // FILE: common.kt
package common package common
expect fun foo() <!NO_ACTUAL_FOR_EXPECT{JVM}, NO_ACTUAL_FOR_EXPECT{JS}!>expect fun foo()<!>
// MODULE: m2-jvm()()(m1-common) // MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt // FILE: jvm.kt
@@ -10,8 +10,8 @@ expect fun f4(s: () -> String)
expect inline fun f5(s: () -> String) expect inline fun f5(s: () -> String)
expect inline fun f6(crossinline s: () -> String) expect inline fun f6(crossinline s: () -> String)
expect fun f7(x: Any) <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun f7(x: Any)<!>
expect fun f8(vararg x: Any) <!NO_ACTUAL_FOR_EXPECT{JVM}!>expect fun f8(vararg x: Any)<!>
// MODULE: m2-jvm()()(m1-common) // MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt // FILE: jvm.kt
@@ -80,7 +80,7 @@ class JvmBackendDiagnosticsHandler(testServices: TestServices) : JvmBinaryArtifa
val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath[ktFile.virtualFilePath] ?: continue val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath[ktFile.virtualFilePath] ?: continue
ktDiagnostics.forEach { ktDiagnostics.forEach {
val metaInfos = val metaInfos =
it.toMetaInfos(testFile, globalMetadataInfoHandler, false, false) it.toMetaInfos(module, testFile, globalMetadataInfoHandler, false, false)
globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos) globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos)
} }
} }
@@ -0,0 +1,48 @@
/*
* Copyright 2010-2023 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.test.backend.ir
import org.jetbrains.kotlin.backend.common.actualizer.IrActualizer
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.compilerConfigurationProvider
class ActualizerOnlyFacade(
val testServices: TestServices,
) : AbstractTestFacade<IrBackendInput, IrBackendInput>() {
override fun transform(module: TestModule, inputArtifact: IrBackendInput): IrBackendInput {
if (module.useIrActualizer()) {
when (inputArtifact) {
is IrBackendInput.JvmIrBackendInput ->
IrActualizer.actualize(
inputArtifact.backendInput.irModuleFragment,
inputArtifact.dependentInputs.map { it.irModuleFragment },
inputArtifact.state.diagnosticReporter,
inputArtifact.state.languageVersionSettings
)
is IrBackendInput.JsIrBackendInput ->
IrActualizer.actualize(
inputArtifact.mainModuleFragment,
inputArtifact.dependentModuleFragments,
inputArtifact.diagnosticsCollector,
testServices.compilerConfigurationProvider.getCompilerConfiguration(module).languageVersionSettings
)
}
}
return inputArtifact
}
private fun TestModule.useIrActualizer(): Boolean {
return frontendKind == FrontendKinds.FIR && languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)
}
override val inputKind: TestArtifactKind<IrBackendInput> = BackendKinds.IrBackend
override val outputKind: TestArtifactKind<IrBackendInput> = BackendKinds.IrBackend
override fun shouldRunAnalysis(module: TestModule): Boolean = true
}
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
import org.jetbrains.kotlin.ir.backend.js.KotlinFileSerializedData import org.jetbrains.kotlin.ir.backend.js.KotlinFileSerializedData
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
@@ -36,6 +37,7 @@ sealed class IrBackendInput : ResultingArtifact.BackendInput<IrBackendInput>() {
val sourceFiles: List<KtSourceFile>, val sourceFiles: List<KtSourceFile>,
val icData: List<KotlinFileSerializedData>, val icData: List<KotlinFileSerializedData>,
val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>, // TODO: abstract from descriptors val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>, // TODO: abstract from descriptors
val diagnosticsCollector: BaseDiagnosticsCollector,
val hasErrors: Boolean, val hasErrors: Boolean,
val serializeSingleFile: (KtSourceFile) -> ProtoBuf.PackageFragment val serializeSingleFile: (KtSourceFile) -> ProtoBuf.PackageFragment
) : IrBackendInput() { ) : IrBackendInput() {
@@ -0,0 +1,47 @@
/*
* Copyright 2010-2023 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.test.backend.ir
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
import org.jetbrains.kotlin.test.FirParser
import org.jetbrains.kotlin.test.backend.handlers.AbstractIrHandler
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue
import org.jetbrains.kotlin.test.frontend.fir.handlers.diagnosticCodeMetaInfos
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.*
class IrDiagnosticsHandler(testServices: TestServices) : AbstractIrHandler(testServices) {
private val globalMetadataInfoHandler: GlobalMetadataInfoHandler
get() = testServices.globalMetadataInfoHandler
private val diagnosticsService: DiagnosticsService
get() = testServices.diagnosticsService
override fun processModule(module: TestModule, info: IrBackendInput) {
val diagnosticsByFilePath = when (info) {
is IrBackendInput.JvmIrBackendInput -> (info.state.diagnosticReporter as BaseDiagnosticsCollector).diagnosticsByFilePath
is IrBackendInput.JsIrBackendInput -> info.diagnosticsCollector.diagnosticsByFilePath
}
for (currentModule in testServices.moduleStructure.modules) {
val lightTreeComparingModeEnabled = FirDiagnosticsDirectives.COMPARE_WITH_LIGHT_TREE in currentModule.directives
val lightTreeEnabled = currentModule.directives.singleOrZeroValue(FirDiagnosticsDirectives.FIR_PARSER) == FirParser.LightTree
for (file in currentModule.files) {
val diagnostics = diagnosticsByFilePath["/" + file.relativePath]
if (diagnostics != null && diagnostics.isNotEmpty()) {
val diagnosticsMetadataInfos =
diagnostics.diagnosticCodeMetaInfos(
module, file, diagnosticsService, globalMetadataInfoHandler,
lightTreeEnabled, lightTreeComparingModeEnabled
)
globalMetadataInfoHandler.addMetadataInfosForFile(file, diagnosticsMetadataInfos)
}
}
}
}
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
}
@@ -36,7 +36,12 @@ class JvmIrBackendFacade(
} }
if (module.useIrActualizer()) { if (module.useIrActualizer()) {
IrActualizer.actualize(inputArtifact.backendInput.irModuleFragment, inputArtifact.dependentInputs.map { it.irModuleFragment }) IrActualizer.actualize(
inputArtifact.backendInput.irModuleFragment,
inputArtifact.dependentInputs.map { it.irModuleFragment },
inputArtifact.state.diagnosticReporter,
inputArtifact.state.languageVersionSettings
)
} }
val state = inputArtifact.state val state = inputArtifact.state
@@ -110,6 +110,7 @@ class ClassicFrontend2IrConverter(
sourceFiles.map(::KtPsiSourceFile), sourceFiles.map(::KtPsiSourceFile),
icData, icData,
expectDescriptorToSymbol = expectDescriptorToSymbol, expectDescriptorToSymbol = expectDescriptorToSymbol,
diagnosticsCollector = DiagnosticReporterFactory.createReporter(),
hasErrors hasErrors
) { file -> ) { file ->
metadataSerializer.serializeScope(file, analysisResult.bindingContext, moduleFragment.descriptor) metadataSerializer.serializeScope(file, analysisResult.bindingContext, moduleFragment.descriptor)
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.diagnostics.KtDiagnostic import org.jetbrains.kotlin.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.fir.AbstractFirAnalyzerFacade import org.jetbrains.kotlin.fir.AbstractFirAnalyzerFacade
@@ -114,6 +115,7 @@ class Fir2IrJsResultsConverter(
sourceFiles, sourceFiles,
configuration.incrementalDataProvider?.getSerializedData(sourceFiles) ?: emptyList(), configuration.incrementalDataProvider?.getSerializedData(sourceFiles) ?: emptyList(),
expectDescriptorToSymbol = mutableMapOf(), expectDescriptorToSymbol = mutableMapOf(),
diagnosticsCollector = DiagnosticReporterFactory.createReporter(),
hasErrors = hasErrors hasErrors = hasErrors
) { file -> ) { file ->
val (firFile, components) = firFilesAndComponentsBySourceFile[file] val (firFile, components) = firFilesAndComponentsBySourceFile[file]
@@ -15,14 +15,11 @@ import org.jetbrains.kotlin.diagnostics.rendering.Renderers
import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.references.FirNamedReference
import org.jetbrains.kotlin.fir.renderForDebugInfo import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.SymbolInternals import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
@@ -31,6 +28,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid
import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.platform.isCommon
import org.jetbrains.kotlin.platform.isJs
import org.jetbrains.kotlin.platform.jvm.isJvm
import org.jetbrains.kotlin.platform.konan.isNative
import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtQualifiedExpression import org.jetbrains.kotlin.psi.KtQualifiedExpression
import org.jetbrains.kotlin.resolve.AnalyzingUtils import org.jetbrains.kotlin.resolve.AnalyzingUtils
@@ -79,25 +80,14 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
if (LanguageSettingsDirectives.API_VERSION in currentModule.directives) { if (LanguageSettingsDirectives.API_VERSION in currentModule.directives) {
diagnostics = diagnostics.filter { it.factory.name != FirErrors.NEWER_VERSION_IN_SINCE_KOTLIN.name } diagnostics = diagnostics.filter { it.factory.name != FirErrors.NEWER_VERSION_IN_SINCE_KOTLIN.name }
} }
val diagnosticsMetadataInfos = diagnostics.flatMap { diagnostic -> val diagnosticsMetadataInfos =
if (!diagnosticsService.shouldRenderDiagnostic( diagnostics.diagnosticCodeMetaInfos(
currentModule, currentModule, file,
diagnostic.factory.name, diagnosticsService, globalMetadataInfoHandler,
diagnostic.severity lightTreeEnabled, lightTreeComparingModeEnabled
)
) return@flatMap emptyList()
// SYNTAX errors will be reported later
if (diagnostic.factory == FirSyntaxErrors.SYNTAX) return@flatMap emptyList()
if (!diagnostic.isValid) return@flatMap emptyList()
diagnostic.toMetaInfos(
file,
globalMetadataInfoHandler,
lightTreeEnabled,
lightTreeComparingModeEnabled
) )
}
globalMetadataInfoHandler.addMetadataInfosForFile(file, diagnosticsMetadataInfos) globalMetadataInfoHandler.addMetadataInfosForFile(file, diagnosticsMetadataInfos)
collectSyntaxDiagnostics(file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled) collectSyntaxDiagnostics(currentModule, file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled)
collectDebugInfoDiagnostics(currentModule, file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled) collectDebugInfoDiagnostics(currentModule, file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled)
} }
} }
@@ -105,6 +95,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
@OptIn(InternalDiagnosticFactoryMethod::class) @OptIn(InternalDiagnosticFactoryMethod::class)
private fun collectSyntaxDiagnostics( private fun collectSyntaxDiagnostics(
module: TestModule,
testFile: TestFile, testFile: TestFile,
firFile: FirFile, firFile: FirFile,
lightTreeEnabled: Boolean, lightTreeEnabled: Boolean,
@@ -114,6 +105,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
AnalyzingUtils.getSyntaxErrorRanges(firFile.psi!!).flatMap { AnalyzingUtils.getSyntaxErrorRanges(firFile.psi!!).flatMap {
FirSyntaxErrors.SYNTAX.on(KtRealPsiSourceElement(it), positioningStrategy = null) FirSyntaxErrors.SYNTAX.on(KtRealPsiSourceElement(it), positioningStrategy = null)
.toMetaInfos( .toMetaInfos(
module,
testFile, testFile,
globalMetadataInfoHandler1 = globalMetadataInfoHandler, globalMetadataInfoHandler1 = globalMetadataInfoHandler,
lightTreeEnabled, lightTreeEnabled,
@@ -124,6 +116,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
collectLightTreeSyntaxErrors(firFile).flatMap { sourceElement -> collectLightTreeSyntaxErrors(firFile).flatMap { sourceElement ->
FirSyntaxErrors.SYNTAX.on(sourceElement, positioningStrategy = null) FirSyntaxErrors.SYNTAX.on(sourceElement, positioningStrategy = null)
.toMetaInfos( .toMetaInfos(
module,
testFile, testFile,
globalMetadataInfoHandler1 = globalMetadataInfoHandler, globalMetadataInfoHandler1 = globalMetadataInfoHandler,
lightTreeEnabled, lightTreeEnabled,
@@ -237,6 +230,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
val codeMetaInfos = result.flatMap { diagnostic -> val codeMetaInfos = result.flatMap { diagnostic ->
diagnostic.toMetaInfos( diagnostic.toMetaInfos(
module,
testFile, testFile,
globalMetadataInfoHandler, globalMetadataInfoHandler,
lightTreeEnabled, lightTreeEnabled,
@@ -323,6 +317,32 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
} }
fun List<KtDiagnostic>.diagnosticCodeMetaInfos(
module: TestModule,
file: TestFile,
diagnosticsService: DiagnosticsService,
globalMetadataInfoHandler: GlobalMetadataInfoHandler,
lightTreeEnabled: Boolean,
lightTreeComparingModeEnabled: Boolean
): List<FirDiagnosticCodeMetaInfo> = flatMap { diagnostic ->
if (!diagnosticsService.shouldRenderDiagnostic(
module,
diagnostic.factory.name,
diagnostic.severity
)
) return@flatMap emptyList()
// SYNTAX errors will be reported later
if (diagnostic.factory == FirSyntaxErrors.SYNTAX) return@flatMap emptyList()
if (!diagnostic.isValid) return@flatMap emptyList()
diagnostic.toMetaInfos(
module,
file,
globalMetadataInfoHandler,
lightTreeEnabled,
lightTreeComparingModeEnabled
)
}
private fun FirTypeRef.isFunctionTypeWithDynamicReceiver(session: FirSession) = private fun FirTypeRef.isFunctionTypeWithDynamicReceiver(session: FirSession) =
coneTypeSafe<ConeKotlinType>()?.isFunctionTypeWithDynamicReceiver(session) == true coneTypeSafe<ConeKotlinType>()?.isFunctionTypeWithDynamicReceiver(session) == true
@@ -498,6 +518,7 @@ class PsiLightTreeMetaInfoProcessor(testServices: TestServices) : AbstractTwoAtt
} }
fun KtDiagnostic.toMetaInfos( fun KtDiagnostic.toMetaInfos(
module: TestModule,
file: TestFile, file: TestFile,
globalMetadataInfoHandler1: GlobalMetadataInfoHandler, globalMetadataInfoHandler1: GlobalMetadataInfoHandler,
lightTreeEnabled: Boolean, lightTreeEnabled: Boolean,
@@ -513,6 +534,16 @@ fun KtDiagnostic.toMetaInfos(
if (lightTreeComparingModeEnabled) { if (lightTreeComparingModeEnabled) {
metaInfo.attributes += if (lightTreeEnabled) PsiLightTreeMetaInfoProcessor.LT else PsiLightTreeMetaInfoProcessor.PSI metaInfo.attributes += if (lightTreeEnabled) PsiLightTreeMetaInfoProcessor.LT else PsiLightTreeMetaInfoProcessor.PSI
} }
if (file !in module.files) {
val targetPlatform = module.targetPlatform
metaInfo.attributes += when {
targetPlatform.isJvm() -> "JVM"
targetPlatform.isJs() -> "JS"
targetPlatform.isNative() -> "NATIVE"
targetPlatform.isCommon() -> "COMMON"
else -> error("Should not be here")
}
}
metaInfo metaInfo
} }
@@ -9,17 +9,16 @@ import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.symbols.FirLazyDeclarationResolver import org.jetbrains.kotlin.fir.symbols.FirLazyDeclarationResolver
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.test.backend.ir.ActualizerOnlyFacade
import org.jetbrains.kotlin.test.bind import org.jetbrains.kotlin.test.backend.ir.IrDiagnosticsHandler
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.builders.configureFirHandlersStep import org.jetbrains.kotlin.test.builders.configureFirHandlersStep
import org.jetbrains.kotlin.test.builders.firHandlersStep import org.jetbrains.kotlin.test.builders.firHandlersStep
import org.jetbrains.kotlin.test.coerce import org.jetbrains.kotlin.test.builders.irHandlersStep
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.WITH_EXTENDED_CHECKERS import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.WITH_EXTENDED_CHECKERS
import org.jetbrains.kotlin.test.FirParser
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.JDK_KIND import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.JDK_KIND
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.WITH_REFLECT import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.WITH_REFLECT
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
@@ -49,6 +48,25 @@ abstract class AbstractFirDiagnosticTestBase(val parser: FirParser) : AbstractKo
abstract class AbstractFirPsiDiagnosticTest : AbstractFirDiagnosticTestBase(FirParser.Psi) abstract class AbstractFirPsiDiagnosticTest : AbstractFirDiagnosticTestBase(FirParser.Psi)
abstract class AbstractFirLightTreeDiagnosticsTest : AbstractFirDiagnosticTestBase(FirParser.LightTree) abstract class AbstractFirLightTreeDiagnosticsTest : AbstractFirDiagnosticTestBase(FirParser.LightTree)
abstract class AbstractFirWithActualizerDiagnosticsTest(val parser: FirParser) : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
override fun TestConfigurationBuilder.configuration() {
configureFirParser(parser)
baseFirDiagnosticTestConfiguration()
facadeStep(::Fir2IrResultsConverter)
facadeStep(::ActualizerOnlyFacade)
irHandlersStep {
useHandlers(
::IrDiagnosticsHandler
)
}
}
}
open class AbstractFirPsiWithActualizerDiagnosticsTest : AbstractFirWithActualizerDiagnosticsTest(FirParser.Psi)
open class AbstractFirLightTreeWithActualizerDiagnosticsTest : AbstractFirWithActualizerDiagnosticsTest(FirParser.LightTree)
fun TestConfigurationBuilder.configurationForClassicAndFirTestsAlongside() { fun TestConfigurationBuilder.configurationForClassicAndFirTestsAlongside() {
useAfterAnalysisCheckers( useAfterAnalysisCheckers(
::FirIdenticalChecker, ::FirIdenticalChecker,
@@ -201,17 +201,33 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
testGroup(testsRoot = "compiler/fir/analysis-tests/tests-gen", testDataRoot = "compiler/testData") { testGroup(testsRoot = "compiler/fir/analysis-tests/tests-gen", testDataRoot = "compiler/testData") {
testClass<AbstractFirPsiDiagnosticTest>(suiteTestClassName = "FirPsiOldFrontendDiagnosticsTestGenerated") { testClass<AbstractFirPsiDiagnosticTest>(suiteTestClassName = "FirPsiOldFrontendDiagnosticsTestGenerated") {
model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedCustomTestdataPattern) model(
"diagnostics/tests", pattern = "^(.*)\\.kts?$",
excludeDirsRecursively = listOf("multiplatform"),
excludedPattern = excludedCustomTestdataPattern
)
model("diagnostics/testsWithStdLib", excludedPattern = excludedCustomTestdataPattern) model("diagnostics/testsWithStdLib", excludedPattern = excludedCustomTestdataPattern)
} }
testClass<AbstractFirPsiWithActualizerDiagnosticsTest>(suiteTestClassName = "FirOldFrontendMPPDiagnosticsWithPsiTestGenerated") {
model("diagnostics/tests/multiplatform", pattern = "^(.*)\\.kts?$", excludedPattern = excludedCustomTestdataPattern)
}
testClass<AbstractFirLightTreeDiagnosticsTest>( testClass<AbstractFirLightTreeDiagnosticsTest>(
suiteTestClassName = "FirLightTreeOldFrontendDiagnosticsTestGenerated" suiteTestClassName = "FirLightTreeOldFrontendDiagnosticsTestGenerated"
) { ) {
model("diagnostics/tests", excludedPattern = excludedCustomTestdataPattern) model(
"diagnostics/tests",
excludeDirsRecursively = listOf("multiplatform"),
excludedPattern = excludedCustomTestdataPattern
)
model("diagnostics/testsWithStdLib", excludedPattern = excludedCustomTestdataPattern) model("diagnostics/testsWithStdLib", excludedPattern = excludedCustomTestdataPattern)
} }
testClass<AbstractFirLightTreeWithActualizerDiagnosticsTest>(suiteTestClassName = "FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated") {
model("diagnostics/tests/multiplatform", pattern = "^(.*)\\.kts?$", excludedPattern = excludedCustomTestdataPattern)
}
testClass<AbstractFirPsiForeignAnnotationsSourceJavaTest>( testClass<AbstractFirPsiForeignAnnotationsSourceJavaTest>(
suiteTestClassName = "FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated" suiteTestClassName = "FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated"
) { ) {
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.cli.js.klib.serializeFirKlib
import org.jetbrains.kotlin.cli.js.klib.transformFirToIr import org.jetbrains.kotlin.cli.js.klib.transformFirToIr
import org.jetbrains.kotlin.codegen.ProjectInfo import org.jetbrains.kotlin.codegen.ProjectInfo
import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.ir.backend.js.* import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
@@ -65,7 +66,7 @@ abstract class FirAbstractInvalidationTest(
) )
if (outputs != null) { if (outputs != null) {
val irResult = transformFirToIr(moduleStructure, outputs) val irResult = transformFirToIr(moduleStructure, outputs, diagnosticsReporter)
serializeFirKlib( serializeFirKlib(
moduleStructure = moduleStructure, moduleStructure = moduleStructure,
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.ir.backend.js.JsFactories import org.jetbrains.kotlin.ir.backend.js.JsFactories
import org.jetbrains.kotlin.ir.backend.js.resolverLogger import org.jetbrains.kotlin.ir.backend.js.resolverLogger
@@ -60,9 +61,17 @@ class FirJsKlibBackendFacade(
// TODO: consider avoiding repeated libraries resolution // TODO: consider avoiding repeated libraries resolution
val libraries = resolveJsLibraries(module, testServices, configuration) val libraries = resolveJsLibraries(module, testServices, configuration)
// TODO: find out how to pass diagnostics to the test infra in this case
val diagnosticReporter = DiagnosticReporterFactory.createReporter()
if (firstTimeCompilation) { if (firstTimeCompilation) {
if (module.frontendKind == FrontendKinds.FIR && module.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) { if (module.frontendKind == FrontendKinds.FIR && module.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) {
IrActualizer.actualize(inputArtifact.mainModuleFragment, inputArtifact.dependentModuleFragments) IrActualizer.actualize(
inputArtifact.mainModuleFragment,
inputArtifact.dependentModuleFragments,
diagnosticReporter,
configuration.languageVersionSettings
)
} }
serializeModuleIntoKlib( serializeModuleIntoKlib(
@@ -12,11 +12,16 @@ import org.jetbrains.kotlin.backend.konan.serialization.KonanManglerIr
import org.jetbrains.kotlin.builtins.DefaultBuiltIns import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter
import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentTypeTransformer import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentTypeTransformer
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.fir.backend.Fir2IrExtensions
import org.jetbrains.kotlin.fir.backend.Fir2IrResult
import org.jetbrains.kotlin.fir.backend.Fir2IrVisibilityConverter
import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
import org.jetbrains.kotlin.fir.pipeline.convertToIrAndActualize import org.jetbrains.kotlin.fir.pipeline.convertToIrAndActualize
import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.incremental.components.LookupTracker
@@ -59,6 +64,7 @@ internal fun PhaseContext.fir2Ir(
// Yes, just to all of them. // Yes, just to all of them.
moduleDescriptor.setDependencies(ArrayList(dependencies)) moduleDescriptor.setDependencies(ArrayList(dependencies))
} }
val diagnosticsReporter = DiagnosticReporterFactory.createPendingReporter()
val fir2irResult = input.firResult.convertToIrAndActualize( val fir2irResult = input.firResult.convertToIrAndActualize(
fir2IrExtensions, fir2IrExtensions,
@@ -67,6 +73,8 @@ internal fun PhaseContext.fir2Ir(
signatureComposerCreator = null, signatureComposerCreator = null,
irMangler = KonanManglerIr, irMangler = KonanManglerIr,
visibilityConverter = Fir2IrVisibilityConverter.Default, visibilityConverter = Fir2IrVisibilityConverter.Default,
diagnosticReporter = diagnosticsReporter,
languageVersionSettings = configuration.languageVersionSettings,
kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance, kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance,
).also { ).also {
(it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors } (it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors }
@@ -77,6 +85,14 @@ internal fun PhaseContext.fir2Ir(
val symbols = createKonanSymbols(fir2irResult) val symbols = createKonanSymbols(fir2irResult)
// TODO KT-55580 Invoke CopyDefaultValuesToActualPhase, same as PsiToir phase does. // TODO KT-55580 Invoke CopyDefaultValuesToActualPhase, same as PsiToir phase does.
val renderDiagnosticNames = configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
FirDiagnosticsCompilerResultsReporter.reportToMessageCollector(diagnosticsReporter, messageCollector, renderDiagnosticNames)
if (diagnosticsReporter.hasErrors) {
throw KonanCompilationException("Compilation failed: there were some diagnostics during fir2ir")
}
return Fir2IrOutput(input.firResult, fir2irResult, symbols) return Fir2IrOutput(input.firResult, fir2irResult, symbols)
} }