diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.kt new file mode 100644 index 00000000000..2e46ea04ee0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.kt @@ -0,0 +1,95 @@ +class None +class In +class Out + +fun a1(value: None) {} +fun a2(value: None) {} +fun a3(value: None) {} + +fun a4(value: In) {} +fun a5(value: In) {} +fun a6(value: In) {} + +fun a7(value: Out) {} +fun a8(value: Out) {} +fun a9(value: Out) {} + +typealias A1 = None +typealias A2 = None +typealias A3 = None + +typealias A4<in K> = None +typealias A5<in K> = None +typealias A6<in K> = None + +typealias A7<out K> = None +typealias A8<out K> = None +typealias A9<out K> = None + +typealias A10 = In +typealias A11 = In +typealias A12 = In + +typealias A13<in K> = In +typealias A14<in K> = In +typealias A15<in K> = In + +typealias A16<out K> = In +typealias A17<out K> = In +typealias A18<out K> = In + +typealias A19 = Out +typealias A20 = Out +typealias A21 = Out + +typealias A22<in K> = Out +typealias A23<in K> = Out +typealias A24<in K> = Out + +typealias A25<out K> = Out +typealias A26<out K> = Out +typealias A27<out K> = Out + +class Outer { + inner class Intermediate { + inner class Inner { + + } + } +} + +fun test1(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() + +fun test2(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() +fun test3(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() + +fun test4(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() +fun test5(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() + +fun test6(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() +fun test7(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() + +fun test8(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() +fun test9(): Outer.Intermediate.Inner = Outer().Intermediate().Inner() + +class InOuter { + inner class OutIntermediate { + inner class InInner { + + } + } +} + +fun test10(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() + +fun test11(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() +fun test12(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() + +fun test13(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() +fun test14(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() + +fun test15(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() +fun test16(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() + +fun test17(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() +fun test18(): InOuter.OutIntermediate.InInner = InOuter().OutIntermediate().InInner() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.txt new file mode 100644 index 00000000000..8c5f49a4850 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.txt @@ -0,0 +1,158 @@ +FILE: conflictingProjection.kt + public final class None : R|kotlin/Any| { + public constructor(): R|None| { + super() + } + + } + public final class In : R|kotlin/Any| { + public constructor(): R|In| { + super() + } + + } + public final class Out : R|kotlin/Any| { + public constructor(): R|Out| { + super() + } + + } + public final fun a1(value: R|None|): R|kotlin/Unit| { + } + public final fun a2(value: R|None|): R|kotlin/Unit| { + } + public final fun a3(value: R|None|): R|kotlin/Unit| { + } + public final fun a4(value: R|In|): R|kotlin/Unit| { + } + public final fun a5(value: R|In|): R|kotlin/Unit| { + } + public final fun a6(value: R|In|): R|kotlin/Unit| { + } + public final fun a7(value: R|Out|): R|kotlin/Unit| { + } + public final fun a8(value: R|Out|): R|kotlin/Unit| { + } + public final fun a9(value: R|Out|): R|kotlin/Unit| { + } + public final typealias A1 = R|None| + public final typealias A2 = R|None| + public final typealias A3 = R|None| + public final typealias A4 = R|None| + public final typealias A5 = R|None| + public final typealias A6 = R|None| + public final typealias A7 = R|None| + public final typealias A8 = R|None| + public final typealias A9 = R|None| + public final typealias A10 = R|In| + public final typealias A11 = R|In| + public final typealias A12 = R|In| + public final typealias A13 = R|In| + public final typealias A14 = R|In| + public final typealias A15 = R|In| + public final typealias A16 = R|In| + public final typealias A17 = R|In| + public final typealias A18 = R|In| + public final typealias A19 = R|Out| + public final typealias A20 = R|Out| + public final typealias A21 = R|Out| + public final typealias A22 = R|Out| + public final typealias A23 = R|Out| + public final typealias A24 = R|Out| + public final typealias A25 = R|Out| + public final typealias A26 = R|Out| + public final typealias A27 = R|Out| + public final class Outer : R|kotlin/Any| { + public constructor(): R|Outer| { + super() + } + + public final inner class Intermediate : R|kotlin/Any| { + public constructor(): R|Outer.Intermediate| { + super() + } + + public final inner class Inner : R|kotlin/Any| { + public constructor(): R|Outer.Intermediate.Inner| { + super() + } + + } + + } + + } + public final fun test1(): R|Outer.Intermediate.Inner| { + ^test1 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test2(): R|Outer.Intermediate.Inner| { + ^test2 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test3(): R|Outer.Intermediate.Inner| { + ^test3 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test4(): R|Outer.Intermediate.Inner| { + ^test4 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test5(): R|Outer.Intermediate.Inner| { + ^test5 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test6(): R|Outer.Intermediate.Inner| { + ^test6 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test7(): R|Outer.Intermediate.Inner| { + ^test7 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test8(): R|Outer.Intermediate.Inner| { + ^test8 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final fun test9(): R|Outer.Intermediate.Inner| { + ^test9 R|/Outer.Outer|().R|/Outer.Intermediate.Intermediate|().R|/Outer.Intermediate.Inner.Inner|() + } + public final class InOuter : R|kotlin/Any| { + public constructor(): R|InOuter| { + super() + } + + public final inner class OutIntermediate : R|kotlin/Any| { + public constructor(): R|InOuter.OutIntermediate| { + super() + } + + public final inner class InInner : R|kotlin/Any| { + public constructor(): R|InOuter.OutIntermediate.InInner| { + super() + } + + } + + } + + } + public final fun test10(): R|InOuter.OutIntermediate.InInner| { + ^test10 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test11(): R|InOuter.OutIntermediate.InInner| { + ^test11 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test12(): R|InOuter.OutIntermediate.InInner| { + ^test12 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test13(): R|InOuter.OutIntermediate.InInner| { + ^test13 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test14(): R|InOuter.OutIntermediate.InInner| { + ^test14 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test15(): R|InOuter.OutIntermediate.InInner| { + ^test15 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test16(): R|InOuter.OutIntermediate.InInner| { + ^test16 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test17(): R|InOuter.OutIntermediate.InInner| { + ^test17 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } + public final fun test18(): R|InOuter.OutIntermediate.InInner| { + ^test18 R|/InOuter.InOuter|().R|/InOuter.OutIntermediate.OutIntermediate|().R|/InOuter.OutIntermediate.InInner.InInner|() + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index e6f6db5e04a..a7e9be1e2a5 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -931,6 +931,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt"); } + @TestMetadata("conflictingProjection.kt") + public void testConflictingProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.kt"); + } + @TestMetadata("constructorInInterface.kt") public void testConstructorInInterface() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 456baab903f..c389ebf3906 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -931,6 +931,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt"); } + @TestMetadata("conflictingProjection.kt") + public void testConflictingProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingProjection.kt"); + } + @TestMetadata("constructorInInterface.kt") public void testConstructorInInterface() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt"); diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt index d45d148d4ae..b98fddb6e36 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt @@ -23,6 +23,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirTypeParametersInObjectChecker, FirConflictsChecker, FirConstructorInInterfaceChecker, + FirConflictingProjectionChecker, ) override val memberDeclarationCheckers: List = listOf( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt new file mode 100644 index 00000000000..f0c438e2c91 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.utils.addToStdlib.safeAs + +object FirConflictingProjectionChecker : FirBasicDeclarationChecker() { + override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + // we can't just check for FirTypedDeclaration + // because it leads to duplicate reports for + // some cases. Maybe we should fix this via not + // visiting the same firs twice instead. + when (declaration) { + is FirPropertyAccessor -> {} + is FirProperty -> { + checkTypeRef(declaration.returnTypeRef, context, reporter) + } + is FirFunction<*> -> { + for (it in declaration.valueParameters) { + checkTypeRef(it.returnTypeRef, context, reporter) + } + checkTypeRef(declaration.returnTypeRef, context, reporter) + } + is FirClass<*> -> { + for (it in declaration.superTypeRefs) { + checkTypeRef(it, context, reporter) + } + } + is FirTypeAlias -> { + for (it in declaration.typeParameters) { + if (it.variance != Variance.INVARIANT) { + reporter.reportVarianceNotAllowed(it.source) + } + } + checkTypeRef(declaration.expandedTypeRef, context, reporter) + } + } + } + + private fun checkTypeRef(typeRef: FirTypeRef, context: CheckerContext, reporter: DiagnosticReporter) { + val declaration = typeRef.safeAs() + ?.coneTypeSafe() + ?.lookupTag + ?.toSymbol(context.session) + ?.fir.safeAs() + ?: return + + declaration.typeParameters.zip(typeRef.coneType.typeArguments).forEach { (proto, actual) -> + val protoVariance = proto.safeAs() + ?.symbol?.fir + ?.variance + ?: return@forEach + + if (protoVariance == Variance.INVARIANT) { + return@forEach + } + + if ( + actual is ConeKotlinTypeProjectionIn && protoVariance == Variance.OUT_VARIANCE || + actual is ConeKotlinTypeProjectionOut && protoVariance == Variance.IN_VARIANCE + ) { + reporter.reportConflictingProjections(typeRef.source, typeRef.coneType.toString()) + return + } + } + } + + private fun DiagnosticReporter.reportConflictingProjections(source: FirSourceElement?, desiredProjection: String) { + source?.let { report(FirErrors.CONFLICTING_PROJECTION.on(it, desiredProjection)) } + } + + private fun DiagnosticReporter.reportVarianceNotAllowed(source: FirSourceElement?) { + source?.let { report(FirErrors.VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED.on(it)) } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index f65fe522952..d1b280b5e5d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CLASS_IN_SUPERTYP import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_OVERLOADS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CAN_BE_VAL +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_PROJECTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_CONSTRUCTOR_DELEGATION_CALL @@ -104,6 +105,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNRESOLVED_LABEL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNRESOLVED_REFERENCE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UPPER_BOUND_VIOLATED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VARIABLE_EXPECTED +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAR_ANNOTATION_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_INVOCATION_KIND import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS @@ -254,6 +256,15 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(TYPE_PARAMETERS_IN_OBJECT, "Type parameters are not allowed for objects") // map.put(ILLEGAL_PROJECTION_USAGE, ...) // & map.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters") + map.put( + CONFLICTING_PROJECTION, + "Projection is conflicting with variance of the corresponding type parameter of {0}. Remove the projection or replace it with ''*''", + TO_STRING + ) + map.put( + VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED, + "Variance annotations are only allowed for type parameters of classes and interfaces" + ) // Redeclarations map.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 865678217bb..557a52420e5 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -125,6 +125,8 @@ object FirErrors { val TYPE_PARAMETERS_IN_OBJECT by error0() val ILLEGAL_PROJECTION_USAGE by error0() val TYPE_PARAMETERS_IN_ENUM by error0() + val CONFLICTING_PROJECTION by error1() + val VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED by error0() // Redeclarations val MANY_COMPANION_OBJECTS by error0() diff --git a/compiler/testData/cli/jvm/conflictingProjection.args b/compiler/testData/cli/jvm/conflictingProjection.args new file mode 100644 index 00000000000..3736b3db902 --- /dev/null +++ b/compiler/testData/cli/jvm/conflictingProjection.args @@ -0,0 +1,4 @@ +$TESTDATA_DIR$/conflictingProjection.kt +-Xuse-fir +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/conflictingProjection.kt b/compiler/testData/cli/jvm/conflictingProjection.kt new file mode 100644 index 00000000000..cd840208cef --- /dev/null +++ b/compiler/testData/cli/jvm/conflictingProjection.kt @@ -0,0 +1,19 @@ +class None +class In +class Out + +fun a1(value: None) {} +fun a2(value: None) {} +fun a3(value: None) {} + +fun a7(value: Out) {} +fun a8(value: Out) {} +fun a9(value: Out) {} + +typealias A1 = None +typealias A2 = None +typealias A3 = None + +typealias A13 = In +typealias A14 = In +typealias A15 = In diff --git a/compiler/testData/cli/jvm/conflictingProjection.out b/compiler/testData/cli/jvm/conflictingProjection.out new file mode 100644 index 00000000000..3b8f7cc4d34 --- /dev/null +++ b/compiler/testData/cli/jvm/conflictingProjection.out @@ -0,0 +1,16 @@ +compiler/testData/cli/jvm/conflictingProjection.kt:10:15: error: projection is conflicting with variance of the corresponding type parameter of Out. Remove the projection or replace it with '*' +fun a8(value: Out) {} + ^ +compiler/testData/cli/jvm/conflictingProjection.kt:17:15: error: variance annotations are only allowed for type parameters of classes and interfaces +typealias A13 = In + ^ +compiler/testData/cli/jvm/conflictingProjection.kt:18:15: error: variance annotations are only allowed for type parameters of classes and interfaces +typealias A14 = In + ^ +compiler/testData/cli/jvm/conflictingProjection.kt:19:15: error: variance annotations are only allowed for type parameters of classes and interfaces +typealias A15 = In + ^ +compiler/testData/cli/jvm/conflictingProjection.kt:19:23: error: projection is conflicting with variance of the corresponding type parameter of In. Remove the projection or replace it with '*' +typealias A15 = In + ^ +COMPILATION_ERROR diff --git a/compiler/testData/diagnostics/tests/declarationChecks/ConflictingAndRedundantProjections.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/ConflictingAndRedundantProjections.fir.kt index c46a729de20..fe6c82df921 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/ConflictingAndRedundantProjections.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/ConflictingAndRedundantProjections.fir.kt @@ -4,11 +4,11 @@ class Inv class X fun f1(p: In) {} -fun f2(p: In) {} +fun f2(p: In) {} fun f3(p: In) {} fun f4(p: Out) {} -fun f5(p: Out) {} +fun f5(p: Out) {} fun f6(p: Out) {} fun f6(p: Inv) {} diff --git a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt index 30954aabfef..10dbcc218b1 100644 --- a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt @@ -51,7 +51,7 @@ val String.x1 get() = "" fun bar1(f: KFunction2) {} -fun bar2(f: KFunction2) {} +fun bar2(f: KFunction2) {} fun bar3(f: Any?) {} diff --git a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/genericWithProjection.fir.kt b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/genericWithProjection.fir.kt index 0d0742be152..5b61a9298d8 100644 --- a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/genericWithProjection.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/genericWithProjection.fir.kt @@ -7,5 +7,5 @@ class In() { fun test1(x: In): Unit = x.f("1") fun test2(x: In): Unit = x.f("1") -fun test3(x: In): Unit = x.f("1") +fun test3(x: In): Unit = x.f("1") fun test4(x: In<*>): Unit = x.f("1") \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/conflictingProjections.fir.kt b/compiler/testData/diagnostics/tests/typealias/conflictingProjections.fir.kt index eb078eb386a..03af30bf1f1 100644 --- a/compiler/testData/diagnostics/tests/typealias/conflictingProjections.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/conflictingProjections.fir.kt @@ -6,8 +6,8 @@ interface Out typealias InAlias = In typealias OutAlias = Out -typealias TestOutForIn = In -typealias TestInForOut = Out +typealias TestOutForIn = In +typealias TestInForOut = Out typealias TestOutForInWithinAlias = InAlias typealias TestInForOutWithinAlias = OutAlias diff --git a/compiler/testData/diagnostics/tests/typealias/parameterRestrictions.fir.kt b/compiler/testData/diagnostics/tests/typealias/parameterRestrictions.fir.kt index 8515a4b3cf4..d8e6cad4ce7 100644 --- a/compiler/testData/diagnostics/tests/typealias/parameterRestrictions.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/parameterRestrictions.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_TYPEALIAS_PARAMETER -typealias WithVariance = Int +typealias WithVariance<in X, out Y> = Int typealias WithBounds1 = Int typealias WithBounds2 = Int diff --git a/compiler/testData/diagnostics/tests/typealias/substitutionVariance.fir.kt b/compiler/testData/diagnostics/tests/typealias/substitutionVariance.fir.kt index bb31c55e0fc..351a2a1ab03 100644 --- a/compiler/testData/diagnostics/tests/typealias/substitutionVariance.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/substitutionVariance.fir.kt @@ -6,11 +6,11 @@ class Inv typealias In1 = In typealias In2 = In -typealias In3 = In +typealias In3 = In typealias In4 = In<*> typealias Out1 = Out -typealias Out2 = Out +typealias Out2 = Out typealias Out3 = Out typealias Out4 = Out<*> diff --git a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt index 9e3122e26e6..78d0051f8d3 100644 --- a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt @@ -35,7 +35,7 @@ interface Test { fun neOk6(i: In>) fun neOk7(i: Pair, O>) fun neOk8(i: Inv) - fun neOk9(i: In) + fun neOk9(i: In) fun neOk10(i: Out) fun neOk11(i: Inv) diff --git a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt index 6d68d795ae3..31f2c5717d5 100644 --- a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt @@ -23,7 +23,7 @@ interface Test { var neOk7: Pair, O> var neOk8: Inv var neOk9: Inv - var neOk10: In + var neOk10: In var neOk11: I var neOk12: In diff --git a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt index f2cf351d677..3e048d33525 100644 --- a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt @@ -28,7 +28,7 @@ interface Test { fun neOk5(): Inv fun neOk6(): Pair, I> fun neOk7(): Inv - fun neOk8(): Out + fun neOk8(): Out fun neOk10(): Inv fun neOk11(): Inv diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java index be7b7c7e445..aea6cc1c486 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -140,6 +140,11 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/conflictingOverloads.args"); } + @TestMetadata("conflictingProjection.args") + public void testConflictingProjection() throws Exception { + runTest("compiler/testData/cli/jvm/conflictingProjection.args"); + } + @TestMetadata("coroutinesEnable.args") public void testCoroutinesEnable() throws Exception { runTest("compiler/testData/cli/jvm/coroutinesEnable.args");