diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt index e661e47a6c7..f6138bf0609 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -3399,6 +3399,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE) { firDiagnostic -> + ActualTypeAliasToNullableTypeImpl( + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirErrors.ACTUAL_TYPE_ALIAS_TO_NOTHING) { firDiagnostic -> + ActualTypeAliasToNothingImpl( + firDiagnostic as KtPsiDiagnostic, + token, + ) + } add(FirErrors.ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS) { firDiagnostic -> ActualFunctionWithDefaultArgumentsImpl( firDiagnostic as KtPsiDiagnostic, diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt index c268e869dfd..528445ee15c 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt @@ -2391,6 +2391,14 @@ sealed interface KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = ActualTypeAliasWithComplexSubstitution::class } + interface ActualTypeAliasToNullableType : KtFirDiagnostic { + override val diagnosticClass get() = ActualTypeAliasToNullableType::class + } + + interface ActualTypeAliasToNothing : KtFirDiagnostic { + override val diagnosticClass get() = ActualTypeAliasToNothing::class + } + interface ActualFunctionWithDefaultArguments : KtFirDiagnostic { override val diagnosticClass get() = ActualFunctionWithDefaultArguments::class } diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index bc10e910081..5658b6043fc 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -2884,6 +2884,16 @@ internal class ActualTypeAliasWithComplexSubstitutionImpl( token: KtLifetimeToken, ) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.ActualTypeAliasWithComplexSubstitution +internal class ActualTypeAliasToNullableTypeImpl( + firDiagnostic: KtPsiDiagnostic, + token: KtLifetimeToken, +) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.ActualTypeAliasToNullableType + +internal class ActualTypeAliasToNothingImpl( + firDiagnostic: KtPsiDiagnostic, + token: KtLifetimeToken, +) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.ActualTypeAliasToNothing + internal class ActualFunctionWithDefaultArgumentsImpl( firDiagnostic: KtPsiDiagnostic, token: KtLifetimeToken, diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index 1433380ff10..3e7010aa983 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -1018,4 +1018,26 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simpleHeaderVar.kt"); } } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/typealias") + @TestDataPath("$PROJECT_ROOT") + public class Typealias { + @Test + @TestMetadata("actualTypealiasToNothing.kt") + public void testActualTypealiasToNothing() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt"); + } + + @Test + @TestMetadata("actualTypealiasToNullableType.kt") + public void testActualTypealiasToNullableType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt"); + } + + @Test + public void testAllFilesPresentInTypealias() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/typealias"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + } } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index cad3b6a3e56..03b027bca86 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -1018,4 +1018,26 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simpleHeaderVar.kt"); } } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/typealias") + @TestDataPath("$PROJECT_ROOT") + public class Typealias { + @Test + @TestMetadata("actualTypealiasToNothing.kt") + public void testActualTypealiasToNothing() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt"); + } + + @Test + @TestMetadata("actualTypealiasToNullableType.kt") + public void testActualTypealiasToNullableType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt"); + } + + @Test + public void testAllFilesPresentInTypealias() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/typealias"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + } } diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 335cdc66852..7de25b33cb6 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -1143,6 +1143,8 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") { val ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE by error(PositioningStrategy.DECLARATION_SIGNATURE) val ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE by error(PositioningStrategy.DECLARATION_SIGNATURE) val ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION by error(PositioningStrategy.DECLARATION_SIGNATURE) + val ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE by error(PositioningStrategy.DECLARATION_SIGNATURE) + val ACTUAL_TYPE_ALIAS_TO_NOTHING by error(PositioningStrategy.DECLARATION_SIGNATURE) val ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS by error() val DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS by error { parameter>("expectClassSymbol") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index eed7de0956c..f686e2c9df1 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -619,6 +619,8 @@ object FirErrors { val ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) + val ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) + val ACTUAL_TYPE_ALIAS_TO_NOTHING by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS by error0() val DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS by error2, Collection>>() val ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE by error1>() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirActualTypeAliasChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirActualTypeAliasChecker.kt index 843b45243c9..2af0b3b8b4f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirActualTypeAliasChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirActualTypeAliasChecker.kt @@ -61,5 +61,15 @@ object FirActualTypeAliasChecker : FirTypeAliasChecker() { if (reportActualTypeAliasWithComplexSubstitution) { reporter.reportOn(declaration.source, FirErrors.ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION, context) } + + @OptIn(UnexpandedTypeCheck::class) + // an earlier check ensures we have an ACTUAL_TYPE_ALIAS_NOT_TO_CLASS error on non-expanded type alias + if (expandedTypeRef.isNothing) { + reporter.reportOn(declaration.source, FirErrors.ACTUAL_TYPE_ALIAS_TO_NOTHING, context) + } + + if (expandedTypeRef.isMarkedNullable == true) { + reporter.reportOn(declaration.source, FirErrors.ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE, context) + } } -} \ No newline at end of file +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt index 46c373798ea..4d979140561 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt @@ -58,6 +58,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_MISSING import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPEALIAS_TO_SPECIAL_ANNOTATION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_NOT_TO_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_TO_NOTHING +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ACTUAL_WITHOUT_EXPECT @@ -1823,6 +1825,14 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() { ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION, "Type arguments in the right-hand side of actual type alias should be its type parameters in the same order, e.g. 'actual typealias Foo = Bar'" ) + map.put( + ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE, + "Right-hand side of actual type alias cannot be a nullable type" + ) + map.put( + ACTUAL_TYPE_ALIAS_TO_NOTHING, + "Right-hand side of actual type alias cannot be of type kotlin.Nothing" + ) map.put( ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS, "Actual function cannot have default argument values, they should be declared in the expected function" diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index f3967f6a7a0..6453c817f56 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -807,6 +807,8 @@ public interface Errors { ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 ACTUAL_TYPE_ALIAS_TO_NOTHING = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(ERROR); DiagnosticFactory2> DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS = DiagnosticFactory2.create(ERROR); DiagnosticFactory1 ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE = diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 17da228427c..6cfb8b0b0ed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -361,6 +361,8 @@ public class DefaultErrorMessages { MAP.put(ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE, "Aliased class should not have type parameters with declaration-site variance"); MAP.put(ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE, "Right-hand side of actual type alias cannot contain use-site variance or star projections"); MAP.put(ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION, "Type arguments in the right-hand side of actual type alias should be its type parameters in the same order, e.g. 'actual typealias Foo = Bar'"); + MAP.put(ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE, "Right-hand side of actual type alias cannot be a nullable type"); + MAP.put(ACTUAL_TYPE_ALIAS_TO_NOTHING, "Right-hand side of actual type alias cannot be of type kotlin.Nothing"); MAP.put(ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS, "Actual function cannot have default argument values, they should be declared in the expected function"); MAP.put(ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE, "Parameter ''{0}'' has conflicting values in the expected and actual annotation", NAME); MAP.put(DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 7f0594dcf79..b92395f4177 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -191,6 +191,16 @@ class DeclarationsChecker( trace.report(ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION.on(declaration)) return } + + if (rhs.isNothing()) { + trace.report(ACTUAL_TYPE_ALIAS_TO_NOTHING.on(declaration)) + return + } + + if (rhs.isMarkedNullable) { + trace.report(ACTUAL_TYPE_ALIAS_TO_NULLABLE_TYPE.on(declaration)) + return + } } private fun getUsedTypeAliasParameters(type: KotlinType, typeAlias: TypeAliasDescriptor): Set = diff --git a/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.fir.kt new file mode 100644 index 00000000000..b0ba8085167 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.fir.kt @@ -0,0 +1,13 @@ +// MODULE: m1-common +// FILE: common.kt + +expect class E01 +expect class E02 + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt + +typealias MyNothing = Nothing + +actual typealias E01 = Nothing +actual typealias E02 = MyNothing diff --git a/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt new file mode 100644 index 00000000000..3d99a97d13d --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt @@ -0,0 +1,13 @@ +// MODULE: m1-common +// FILE: common.kt + +expect class E01 +expect class E02 + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt + +typealias MyNothing = Nothing + +actual typealias E01 = Nothing +actual typealias E02 = MyNothing diff --git a/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt new file mode 100644 index 00000000000..8837ebe1926 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt @@ -0,0 +1,14 @@ +// FIR_IDENTICAL +// MODULE: m1-common +// FILE: common.kt + +expect class E01 +expect class E02 + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt + +typealias MyNullable = String? + +actual typealias E01 = String? +actual typealias E02 = MyNullable diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/common.kt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/common.kt new file mode 100644 index 00000000000..22566666a3a --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/common.kt @@ -0,0 +1,2 @@ +expect class E01 +expect class E02 diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt new file mode 100644 index 00000000000..ef7e19d26d6 --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt @@ -0,0 +1,4 @@ +typealias MyNothing = Nothing + +actual typealias E01 = Nothing +actual typealias E02 = MyNothing diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/output.txt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/output.txt new file mode 100644 index 00000000000..f0b81fda85e --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/output.txt @@ -0,0 +1,13 @@ +-- Common -- +Exit code: OK +Output: + +-- JVM -- +Exit code: COMPILATION_ERROR +Output: +compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:3:1: error: right-hand side of actual type alias cannot be of type kotlin.Nothing +actual typealias E01 = Nothing +^ +compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:4:1: error: right-hand side of actual type alias should be a class, not another type alias +actual typealias E02 = MyNothing +^ diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/common.kt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/common.kt new file mode 100644 index 00000000000..22566666a3a --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/common.kt @@ -0,0 +1,2 @@ +expect class E01 +expect class E02 diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/jvm.kt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/jvm.kt new file mode 100644 index 00000000000..69df3ba74e7 --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/jvm.kt @@ -0,0 +1,4 @@ +typealias MyNullable = String? + +actual typealias E01 = String? +actual typealias E02 = MyNullable diff --git a/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/output.txt b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/output.txt new file mode 100644 index 00000000000..8f8ee891c33 --- /dev/null +++ b/compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/output.txt @@ -0,0 +1,13 @@ +-- Common -- +Exit code: OK +Output: + +-- JVM -- +Exit code: COMPILATION_ERROR +Output: +compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/jvm.kt:3:1: error: right-hand side of actual type alias cannot be a nullable type +actual typealias E01 = String? +^ +compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/jvm.kt:4:1: error: right-hand side of actual type alias should be a class, not another type alias +actual typealias E02 = MyNullable +^ diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 18efb5ff97b..4941edc8aad 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -23581,6 +23581,28 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simpleHeaderVar.kt"); } } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/typealias") + @TestDataPath("$PROJECT_ROOT") + public class Typealias { + @Test + @TestMetadata("actualTypealiasToNothing.kt") + public void testActualTypealiasToNothing() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNothing.kt"); + } + + @Test + @TestMetadata("actualTypealiasToNullableType.kt") + public void testActualTypealiasToNullableType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/typealias/actualTypealiasToNullableType.kt"); + } + + @Test + public void testAllFilesPresentInTypealias() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/typealias"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java index 3629717ec93..4b7312bfa59 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java @@ -449,6 +449,16 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("actualTypealiasToNothing") + public void testActualTypealiasToNothing() throws Exception { + runTest("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/"); + } + + @TestMetadata("actualTypealiasToNullableType") + public void testActualTypealiasToNullableType() throws Exception { + runTest("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType/"); + } + public void testAllFilesPresentInImplTypeAlias() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/multiplatform/implTypeAlias"), Pattern.compile("^([^\\.]+)$"), null, true); } @@ -468,6 +478,32 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform runTest("compiler/testData/multiplatform/implTypeAlias/nestedClassesViaTypeAlias/"); } + @TestMetadata("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ActualTypealiasToNothing extends AbstractMultiPlatformIntegrationTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInActualTypealiasToNothing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ActualTypealiasToNullableType extends AbstractMultiPlatformIntegrationTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInActualTypealiasToNullableType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNullableType"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + @TestMetadata("compiler/testData/multiplatform/implTypeAlias/discriminateHeaderClassInFavorOfTypeAlias") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)