From 721b9b4d8c5eee3c4184c30f1511d0e847e17799 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 23 Jul 2020 17:47:38 +0300 Subject: [PATCH] [FIR] Resolve annotations as calls --- .../arguments/argumentsOfAnnotations.kt | 9 ++++ .../arguments/argumentsOfAnnotations.txt | 43 ++++++++++++++++ .../arguments/argumentsOfJavaAnnotation.kt | 15 ++++++ .../arguments/argumentsOfJavaAnnotation.txt | 7 +++ .../resolve/arguments/integerLiteralTypes.kt | 2 +- .../resolve/arguments/integerLiteralTypes.txt | 2 +- .../javaAnnotationsWithArrayValue.kt | 16 ++++++ .../javaAnnotationsWithArrayValue.txt | 7 +++ .../lowPriorityInResolution.kt | 4 +- .../fir/FirDiagnosticsTestGenerated.java | 15 ++++++ ...DiagnosticsWithLightTreeTestGenerated.java | 15 ++++++ .../generators/CallAndReferenceGenerator.kt | 12 ++--- .../converter/DeclarationsConverter.kt | 8 ++- .../kotlin/fir/builder/RawFirBuilder.kt | 6 ++- .../jetbrains/kotlin/fir/FirCallResolver.kt | 51 +++++++++++++++++++ .../kotlin/fir/resolve/ResolveUtils.kt | 15 ++---- .../inference/ConstraintSystemCompleter.kt | 5 ++ ...rCallCompletionResultsWriterTransformer.kt | 22 ++++++++ .../FirExpressionsResolveTransformer.kt | 29 +++-------- ...irAnnotationArgumentsResolveTransformer.kt | 6 +-- .../fir/expressions/FirExpressionUtil.kt | 4 +- .../box/annotations/mustBeDocumented.kt | 1 - .../AmbigiousAnnotationConstructor.fir.kt | 6 +-- .../AnnotationForClassTypeParameter.fir.kt | 8 +-- .../AnnotationForFunctionTypeParameter.fir.kt | 8 +-- .../annotations/AnnotationIdentifier.fir.kt | 6 +-- ...AnnotationsForPropertyTypeParameter.fir.kt | 6 +-- .../tests/annotations/BasicAnnotations.fir.kt | 2 +- .../annotations/NonAnnotationClass.fir.kt | 2 +- ...sivelyIncorrectlyAnnotatedParameter.fir.kt | 2 +- .../WrongAnnotationArgsOnObject.fir.kt | 4 +- .../enumConst_after.fir.kt | 4 +- .../enumConst_before.fir.kt | 4 +- .../annotationsOnLambdaAsCallArgument.fir.kt | 2 +- .../annotations/atAnnotationResolve.fir.kt | 2 +- .../annotations/deprecatedRepeatable.fir.kt | 4 +- .../illegalRequireKotlinValue.fir.kt | 22 ++++---- .../tests/annotations/kt1860-negative.fir.kt | 10 ++-- .../typeParameterAsAnnotation.fir.kt | 6 +-- .../unresolvedReferenceRange.fir.kt | 10 ++-- .../collectionLiteralsWithVarargs.fir.kt | 4 +- .../tests/deprecated/javaDeprecated.fir.kt | 2 +- .../typeParameterAsUpperBound.fir.kt | 4 +- .../localClasses/localAnnotationClass.fir.kt | 2 +- .../localAnnotationClassError.fir.kt | 2 +- .../tests/modifiers/IllegalModifiers.fir.kt | 2 +- .../kt21515/annotationConstructor.fir.kt | 4 +- .../topLevelAnnotationCall.fir.kt | 6 +-- .../ctrsAnnotationResolve.fir.kt | 4 +- ...assignArrayToVararagInNamedForm_1_3.fir.kt | 4 +- ...assignArrayToVararagInNamedForm_1_4.fir.kt | 2 +- ...signingArraysToVarargsInAnnotations.fir.kt | 6 +-- ...entsInNamedFormAnnDeprecation_after.fir.kt | 6 +-- ...ntsInNamedFormAnnDeprecation_before.fir.kt | 6 +-- .../noAssigningArraysToVarargsFeature.fir.kt | 8 +-- ...tAssigningSingleElementsInNamedForm.fir.kt | 2 +- .../annotationParameters/valueArray.fir.kt | 6 +-- .../valueArrayAndOtherDefault.fir.kt | 10 ++-- .../javaAnnotationWithVarargArgument.fir.kt | 2 +- .../kotlinAnnotationWithVarargArgument.fir.kt | 2 +- .../incorrectJvmPackageName.fir.kt | 10 ++-- .../kClassArrayInAnnotationsInVariance.fir.kt | 4 +- ...kClassArrayInAnnotationsOutVariance.fir.kt | 6 +-- .../kClassInAnnotationsInVariance.fir.kt | 4 +- .../kClassInAnnotationsOutVariance.fir.kt | 6 +-- .../kClass/kClassInvariantTP.fir.kt | 6 +-- .../tooManyArgs.fir.kt | 4 +- .../typeMismatch.fir.kt | 6 +-- .../experimental/wasExperimental.fir.kt | 8 +-- ...ckLowPriorityIsResolvedSuccessfully.fir.kt | 2 +- ...tAnnotationWithUpperBoundConstraint.fir.kt | 4 +- ...xplicitTypeArgumentAsValidInputType.fir.kt | 2 +- .../annotationsForResolve/kt26698.fir.kt | 8 +-- .../annotationsForResolve/kt35210.fir.kt | 12 +++++ .../annotationsForResolve/kt35210.kt | 3 +- .../noInferAndLowPriority.fir.kt | 4 +- .../onlyInputTypeAndJava.fir.kt | 18 +++++++ .../onlyInputTypeAndJava.kt | 3 +- ...putTypeRecursiveBoundAndProjections.fir.kt | 24 +++++++++ ...lyInputTypeRecursiveBoundAndProjections.kt | 1 - .../onlyInputTypes.fir.kt | 2 +- .../onlyInputTypesAndLowPriority.fir.kt | 10 ++-- ...yInputTypesAndTopLevelCapturedTypes.fir.kt | 8 +-- ...putTypesAnnotationWithPlatformTypes.fir.kt | 19 +++++++ ...lyInputTypesAnnotationWithPlatformTypes.kt | 3 +- .../onlyInputTypesCaptured.fir.kt | 4 +- ...nlyInputTypesCommonConstraintSystem.fir.kt | 4 +- .../onlyInputTypesUpperBound.fir.kt | 2 +- .../onlyInputTypesWarning.fir.kt | 2 +- ...resolveWithOnlyInputTypesAnnotation.fir.kt | 6 +-- ...inlineOnlySuppressesNothingToInline.fir.kt | 31 +++++++++++ .../inlineOnlySuppressesNothingToInline.kt | 3 +- .../testsWithStdLib/pureReifiable.fir.kt | 12 +++++ .../testsWithStdLib/pureReifiable.kt | 1 - .../regression/ea70880_illegalJvmName.fir.kt | 6 +-- .../resolve/hidesMembers.fir.kt | 8 +-- .../resolve/hidesMembers2.fir.kt | 10 ++-- .../annotations/javaAnnotation.fir.txt | 7 --- .../annotations/javaAnnotation.kt | 2 + 99 files changed, 529 insertions(+), 232 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/javaAnnotation.fir.txt diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt new file mode 100644 index 00000000000..5d460f57658 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt @@ -0,0 +1,9 @@ +annotation class Ann(val x: Int, val y: String, val z: String = "z") + +@Ann(y = "y", x = 10) +class A + +annotation class AnnVarargs(val x: Int, vararg val y: String, val z: Int) + +@AnnVarargs(1, "a", "b", "c", 2) +class B diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.txt new file mode 100644 index 00000000000..37e0a235660 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.txt @@ -0,0 +1,43 @@ +FILE: argumentsOfAnnotations.kt + public final annotation class Ann : R|kotlin/Annotation| { + public constructor(x: R|kotlin/Int|, y: R|kotlin/String|, z: R|kotlin/String| = String(z)): R|Ann| { + super() + } + + public final val x: R|kotlin/Int| = R|/x| + public get(): R|kotlin/Int| + + public final val y: R|kotlin/String| = R|/y| + public get(): R|kotlin/String| + + public final val z: R|kotlin/String| = R|/z| + public get(): R|kotlin/String| + + } + @R|Ann|(y = String(y), x = Int(10)) public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public final annotation class AnnVarargs : R|kotlin/Annotation| { + public constructor(x: R|kotlin/Int|, vararg y: R|kotlin/Array|, z: R|kotlin/Int|): R|AnnVarargs| { + super() + } + + public final val x: R|kotlin/Int| = R|/x| + public get(): R|kotlin/Int| + + public final val y: R|kotlin/Array| = R|/y| + public get(): R|kotlin/Array| + + public final val z: R|kotlin/Int| = R|/z| + public get(): R|kotlin/Int| + + } + @R|AnnVarargs|(Int(1), String(a), String(b), String(c), Int(2)) public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt new file mode 100644 index 00000000000..53f208b8d12 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt @@ -0,0 +1,15 @@ +// FILE: Ann.java + +public @interface Ann { + String s(); + int x(); + int y() default 1; +} + +// FILE: main.kt + +@Ann(x = 10, s = "") +@Ann(10, "") +@Ann(x = 10, s = "", y = 10) +class A + diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.txt new file mode 100644 index 00000000000..83f09862610 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.txt @@ -0,0 +1,7 @@ +FILE: main.kt + @R|Ann|(x = Int(10), s = String()) @R|Ann|(Int(10), String()) @R|Ann|(x = Int(10), s = String(), y = Int(10)) public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt index 99a2eb9fdc6..0aa726d7740 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt @@ -43,6 +43,6 @@ annotation class Ann(val x: Byte) @Ann(10) fun test_6() { - @Ann(300) + @Ann(300) val x = "" } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.txt index 7e2036a595a..e2910694a10 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.txt @@ -61,6 +61,6 @@ FILE: integerLiteralTypes.kt public get(): R|kotlin/Byte| } - @R|Ann|(Int(10)) public final fun test_6(): R|kotlin/Unit| { + @R|Ann|(Byte(10)) public final fun test_6(): R|kotlin/Unit| { @R|Ann|(Int(300)) lval x: R|kotlin/String| = String() } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt new file mode 100644 index 00000000000..836351935b1 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt @@ -0,0 +1,16 @@ +// FILE: Ann.java + +public @interface Ann { + String[] value(); +} + +// FILE: main.kt + +@Ann("a", "b") +fun test_1() {} + +@Ann(arrayOf("a", "b")) +fun test_2() {} + +@Ann(*arrayOf("a", "b")) +fun test_3() {} diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.txt new file mode 100644 index 00000000000..fc1c22ee8fe --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.txt @@ -0,0 +1,7 @@ +FILE: main.kt + @R|Ann|(vararg(String(a), String(b))) public final fun test_1(): R|kotlin/Unit| { + } + @R|Ann|(R|kotlin/arrayOf|(vararg(String(a), String(b)))) public final fun test_2(): R|kotlin/Unit| { + } + @R|Ann|(vararg(*R|kotlin/arrayOf|(vararg(String(a), String(b))))) public final fun test_3(): R|kotlin/Unit| { + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt index 4dfed7822c1..5aefcce5892 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt @@ -1,5 +1,5 @@ @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.LowPriorityInOverloadResolution +@kotlin.internal.LowPriorityInOverloadResolution fun foo(): Int = 1 fun foo(): String = "" @@ -7,4 +7,4 @@ fun foo(): String = "" fun test() { val s = foo() s.length -} \ No newline at end of file +} 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 c6b0cd971c4..6c35950fdd9 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 @@ -445,6 +445,16 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt"); } + @TestMetadata("argumentsOfAnnotations.kt") + public void testArgumentsOfAnnotations() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt"); + } + + @TestMetadata("argumentsOfJavaAnnotation.kt") + public void testArgumentsOfJavaAnnotation() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt"); + } + @TestMetadata("default.kt") public void testDefault() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/default.kt"); @@ -485,6 +495,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/invoke.kt"); } + @TestMetadata("javaAnnotationsWithArrayValue.kt") + public void testJavaAnnotationsWithArrayValue() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt"); + } + @TestMetadata("javaArrayVariance.kt") public void testJavaArrayVariance() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.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 d62df59226d..33fbd67867b 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 @@ -445,6 +445,16 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt"); } + @TestMetadata("argumentsOfAnnotations.kt") + public void testArgumentsOfAnnotations() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt"); + } + + @TestMetadata("argumentsOfJavaAnnotation.kt") + public void testArgumentsOfJavaAnnotation() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt"); + } + @TestMetadata("default.kt") public void testDefault() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/default.kt"); @@ -485,6 +495,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/arguments/invoke.kt"); } + @TestMetadata("javaAnnotationsWithArrayValue.kt") + public void testJavaAnnotationsWithArrayValue() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt"); + } + @TestMetadata("javaArrayVariance.kt") public void testJavaArrayVariance() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt"); diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 6a4078a8028..59089c6a341 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -19,12 +19,12 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.calls.isFunctional -import org.jetbrains.kotlin.fir.resolve.getCorrespondingConstructorReferenceOrNull import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.* @@ -420,16 +420,14 @@ class CallAndReferenceGenerator( fun convertToIrConstructorCall(annotationCall: FirAnnotationCall): IrExpression { val coneType = annotationCall.annotationTypeRef.coneTypeSafe() - val firSymbol = coneType?.lookupTag?.toSymbol(session) as? FirClassSymbol val type = coneType?.toIrType() val symbol = type?.classifierOrNull return annotationCall.convertWithOffsets { startOffset, endOffset -> when (symbol) { is IrClassSymbol -> { val irClass = symbol.owner - val fir = firSymbol?.fir as? FirClass<*> - val irConstructor = fir?.getPrimaryConstructorIfAny()?.let { firConstructor -> - this.declarationStorage.getIrConstructorSymbol(firConstructor.symbol) + val irConstructor = (annotationCall.toResolvedCallableSymbol() as? FirConstructorSymbol)?.let { + this.declarationStorage.getIrConstructorSymbol(it) } if (irConstructor == null) { IrErrorCallExpressionImpl(startOffset, endOffset, type, "No annotation constructor found: ${irClass.name}") @@ -492,13 +490,13 @@ class CallAndReferenceGenerator( val calleeReference = when (call) { is FirFunctionCall -> call.calleeReference is FirDelegatedConstructorCall -> call.calleeReference - is FirAnnotationCall -> call.getCorrespondingConstructorReferenceOrNull(session) + is FirAnnotationCall -> call.calleeReference else -> null } as? FirResolvedNamedReference val function = (calleeReference?.resolvedSymbol as? FirFunctionSymbol<*>)?.fir val valueParameters = function?.valueParameters val argumentMapping = call.argumentMapping - if (argumentMapping != null && argumentMapping.isNotEmpty()) { + if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) { if (valueParameters != null) { return applyArgumentsWithReorderingIfNeeded(call, argumentMapping, valueParameters, annotationMode) } diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 6675974316e..e6c2a49a989 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -38,8 +38,10 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier import org.jetbrains.kotlin.fir.references.builder.buildImplicitThisReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirReferenceForUnresolvedAnnotations import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations +import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.CallableId @@ -321,11 +323,15 @@ class DeclarationsConverter( CONSTRUCTOR_CALLEE -> constructorCalleePair = convertConstructorInvocation(unescapedAnnotation) } } + val name = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("") return buildAnnotationCall { source = unescapedAnnotation.toFirSourceElement() useSiteTarget = annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget annotationTypeRef = constructorCalleePair.first - calleeReference = FirReferenceForUnresolvedAnnotations + calleeReference = buildSimpleNamedReference { + source = this@buildAnnotationCall.source + this.name = name + } extractArgumentsFrom(constructorCalleePair.second, stubMode) } } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 98758ab8c0b..fe54fd30208 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1288,7 +1288,11 @@ class RawFirBuilder( useSiteTarget = annotationEntry.useSiteTarget?.getAnnotationUseSiteTarget() annotationTypeRef = annotationEntry.typeReference.toFirOrErrorType() annotationEntry.extractArgumentsTo(this) - calleeReference = FirReferenceForUnresolvedAnnotations + val name = (annotationTypeRef as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("") + calleeReference = buildSimpleNamedReference { + source = this@buildAnnotationCall.source + this.name = name + } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 8b51bf29cd8..32dd912ff2c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.isInner import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic @@ -36,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind class FirCallResolver( private val components: BodyResolveComponents, @@ -315,6 +317,55 @@ class FirCallResolver( return callResolver.selectDelegatingConstructorCall(delegatedConstructorCall, name, result, callInfo) } + fun resolveAnnotationCall(annotationCall: FirAnnotationCall): FirAnnotationCall? { + val reference = annotationCall.calleeReference as? FirSimpleNamedReference ?: return null + annotationCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent) + + val callInfo = CallInfo( + CallKind.Function, + name = reference.name, + explicitReceiver = null, + annotationCall.argumentList, + isPotentialQualifierPart = false, + typeArguments = emptyList(), + session, + file, + containingDeclarations + ) + + val resolutionResult = createCandidateForAnnotationCall(annotationCall, callInfo) + ?: ResolutionResult(callInfo, CandidateApplicability.HIDDEN, emptyList()) + val resolvedReference = createResolvedNamedReference( + reference, + reference.name, + callInfo, + resolutionResult.candidates, + resolutionResult.applicability, + explicitReceiver = null + ) + + return annotationCall.transformCalleeReference(StoreNameReference, resolvedReference) + } + + private fun createCandidateForAnnotationCall(annotationCall: FirAnnotationCall, callInfo: CallInfo): ResolutionResult? { + val annotationClassSymbol = annotationCall.getCorrespondingClassSymbolOrNull(session) + ?.takeIf { it.fir.classKind == ClassKind.ANNOTATION_CLASS } + ?: return null + var constructorSymbol: FirConstructorSymbol? = null + annotationClassSymbol.fir.buildUseSiteMemberScope(session, scopeSession)?.processDeclaredConstructors { + if (it.fir.isPrimary && constructorSymbol == null) { + constructorSymbol = it + } + } + if (constructorSymbol == null) return null + val candidate = CandidateFactory(components, callInfo).createCandidate( + constructorSymbol!!, + ExplicitReceiverKind.NO_EXPLICIT_RECEIVER + ) + val applicability = resolutionStageRunner.processCandidate(candidate) + return ResolutionResult(callInfo, applicability, listOf(candidate)) + } + @OptIn(PrivateForInline::class) inline fun withNoArgumentsTransform(block: () -> T): T { val oldValue = needTransformArguments diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 78c9acb6231..e94ae90f847 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -469,20 +469,13 @@ private fun FirQualifiedAccess.expressionTypeOrUnitForAssignment(): ConeKotlinTy return StandardClassIds.Unit.constructClassLikeType(emptyArray(), isNullable = false) } -fun FirAnnotationCall.getCorrespondingConstructorReferenceOrNull(session: FirSession): FirResolvedNamedReference? = - annotationTypeRef.coneType.classId?.let { +fun FirAnnotationCall.getCorrespondingClassSymbolOrNull(session: FirSession): FirRegularClassSymbol? { + return annotationTypeRef.coneType.fullyExpandedType(session).classId?.let { if (it.isLocal) { // TODO: How to retrieve local annotaiton's constructor? null } else { - (session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir - ?.getPrimaryConstructorIfAny() - ?.let { annotationConstructor -> - buildResolvedNamedReference { - source = this@getCorrespondingConstructorReferenceOrNull.source - name = it.shortClassName - resolvedSymbol = annotationConstructor.symbol - } - } + (session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol) } } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt index 4a27618c94f..b495049b721 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt @@ -299,6 +299,11 @@ fun FirStatement.processAllContainingCallCandidates(processBlocks: Boolean, proc lhs.processAllContainingCallCandidates(processBlocks, processor) rhs.processAllContainingCallCandidates(processBlocks, processor) } + + is FirAnnotationCall -> { + processCandidateIfApplicable(processor, processBlocks) + arguments.forEach { it.processAllContainingCallCandidates(processBlocks, processor) } + } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 57bab3fb4e2..e78d534a747 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -170,6 +170,28 @@ class FirCallCompletionResultsWriterTransformer( return result.compose() } + override fun transformAnnotationCall( + annotationCall: FirAnnotationCall, + data: ExpectedArgumentType? + ): CompositeTransformResult { + val calleeReference = annotationCall.calleeReference as? FirNamedReferenceWithCandidate + ?: return annotationCall.compose() + annotationCall.transformCalleeReference( + StoreCalleeReference, + calleeReference.toResolvedReference(), + ) + val subCandidate = calleeReference.candidate + val expectedArgumentsTypeMapping = runIf(!calleeReference.isError) { subCandidate.createArgumentsMapping() } + annotationCall.argumentList.transformArguments(this, expectedArgumentsTypeMapping) + if (!calleeReference.isError) { + subCandidate.handleVarargs(annotationCall.argumentList) + subCandidate.argumentMapping?.let { + annotationCall.replaceArgumentList(buildResolvedArgumentList(it)) + } + } + return annotationCall.compose() + } + private fun Candidate.handleVarargs(argumentList: FirArgumentList) { val argumentMapping = this.argumentMapping val varargParameter = argumentMapping?.values?.firstOrNull { it.isVararg } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 37499cc4cbf..3d4f780eab3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -726,35 +726,22 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult { if (annotationCall.resolveStatus == FirAnnotationResolveStatus.Resolved) return annotationCall.compose() - return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.Resolved) + return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.Resolved) } protected fun resolveAnnotationCall( annotationCall: FirAnnotationCall, - data: ResolutionMode, status: FirAnnotationResolveStatus ): CompositeTransformResult { dataFlowAnalyzer.enterAnnotationCall(annotationCall) return withFirArrayOfCallTransformer { - (annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also { - // TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls - it.argumentList.transformArguments(integerLiteralTypeApproximator, null) - annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference -> - val callee = calleeReference.resolvedSymbol.fir as FirFunction<*> - val argumentMapping = mapArguments(it.arguments, callee).toArgumentToParameterMapping() - val varargParameter = callee.valueParameters.firstOrNull { param -> param.isVararg } - if (varargParameter == null) { - it.replaceArgumentList(buildResolvedArgumentList(argumentMapping)) - } else { - val varargParameterTypeRef = varargParameter.returnTypeRef - val arrayType = varargParameterTypeRef.coneType - val newArgumentMapping = remapArgumentsWithVararg(varargParameter, arrayType, it.argumentList, argumentMapping) - it.replaceArgumentList(buildResolvedArgumentList(newArgumentMapping)) - } - } - it.replaceResolveStatus(status) - dataFlowAnalyzer.exitAnnotationCall(it) - }.compose() + annotationCall.transformAnnotationTypeRef(transformer, ResolutionMode.ContextIndependent) + if (status == FirAnnotationResolveStatus.PartiallyResolved) return annotationCall.compose() + val result = callResolver.resolveAnnotationCall(annotationCall) ?: return annotationCall.compose() + callCompleter.completeCall(result, noExpectedType) + result.replaceResolveStatus(status) + dataFlowAnalyzer.exitAnnotationCall(result) + annotationCall.compose() } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt index a71d033e706..1f4314e679d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt @@ -100,7 +100,7 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations( override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult { if (annotationArgumentsMode) { - return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.PartiallyResolved) + return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.PartiallyResolved) } annotationCall.transformAnnotationTypeRef(transformer, data) @@ -110,7 +110,7 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations( return annotationCall.compose() } annotationArgumentsMode = true - return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.PartiallyResolved).also { + return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.PartiallyResolved).also { annotationArgumentsMode = false } } @@ -193,4 +193,4 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations( ): CompositeTransformResult { return augmentedArraySetCall.compose() } -} \ No newline at end of file +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt index 76ca5a40d7d..c2a4577a80f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt @@ -44,7 +44,7 @@ inline val FirCall.argumentMapping: Map? get() = (argumentList as? FirResolvedArgumentList)?.mapping fun FirExpression.toResolvedCallableReference(): FirResolvedNamedReference? { - return (this as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference + return (this as? FirResolvable)?.calleeReference as? FirResolvedNamedReference } fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? { @@ -93,4 +93,4 @@ fun FirBlock.replaceFirstStatement(statement: FirStatement): FirStatement { val existed = statements[0] statements[0] = statement return existed -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/annotations/mustBeDocumented.kt b/compiler/testData/codegen/box/annotations/mustBeDocumented.kt index 0c1435d9b11..27508e408a1 100644 --- a/compiler/testData/codegen/box/annotations/mustBeDocumented.kt +++ b/compiler/testData/codegen/box/annotations/mustBeDocumented.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FULL_JDK // SKIP_JDK6 diff --git a/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.fir.kt b/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.fir.kt index 89d4868b782..c4b1279115c 100644 --- a/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.fir.kt @@ -1,6 +1,6 @@ // !WITH_NEW_INFERENCE import java.util.ArrayList -@ArrayList(1, 1) fun b() {} -@Xoo(x) fun c() {} -@java.lang.Deprecated(x) fun a() {} \ No newline at end of file +@ArrayList(1, 1) fun b() {} +@Xoo(x) fun c() {} +@java.lang.Deprecated(x) fun a() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt index dc3b6defedf..728e16d62e4 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt @@ -1,10 +1,10 @@ annotation class A1 annotation class A2(val some: Int = 12) -class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { - class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { +class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { + class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { fun test() { - class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> + class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt index 45b6124e8c7..edd5a887999 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt @@ -1,12 +1,12 @@ annotation class A1 annotation class A2(val some: Int = 12) -fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> topFun() = 12 +fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> topFun() = 12 class SomeClass { - fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> method() = 12 + fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> method() = 12 fun foo() { - fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> innerFun() = 12 + fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> innerFun() = 12 } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationIdentifier.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationIdentifier.fir.kt index 57427f7f9ee..8de25b7cb85 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationIdentifier.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationIdentifier.fir.kt @@ -6,7 +6,7 @@ annotation class annotation package test -@test.annotation class annotation +@test.annotation class annotation // FILE: other/c.kt @@ -14,6 +14,6 @@ package other annotation class My -@test.annotation class Your +@test.annotation class Your -@My class Our \ No newline at end of file +@My class Our diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt index 14a421e8204..01ae94af87d 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt @@ -3,12 +3,12 @@ annotation class A1 annotation class A2(val some: Int = 12) -val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.topProp: Int get() = 12 +val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.topProp: Int get() = 12 class SomeClass { - val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.field: Int get() = 12 + val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.field: Int get() = 12 fun foo() { val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> localVal = 12 } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.fir.kt index 96404567511..3da14fdb2be 100644 --- a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.fir.kt @@ -3,7 +3,7 @@ annotation class my1(val i : Int) annotation class my2(val i : Int = 0) @my fun foo() {} -@my1 fun foo2() {} +@my1 fun foo2() {} @my1(2) fun foo3() {} @my2() fun foo4() {} @my2 fun foo41() {} diff --git a/compiler/testData/diagnostics/tests/annotations/NonAnnotationClass.fir.kt b/compiler/testData/diagnostics/tests/annotations/NonAnnotationClass.fir.kt index b606948ff6c..e13d425e5de 100644 --- a/compiler/testData/diagnostics/tests/annotations/NonAnnotationClass.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/NonAnnotationClass.fir.kt @@ -1,3 +1,3 @@ class Foo -@Foo class Bar \ No newline at end of file +@Foo class Bar diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.fir.kt index b7696796635..ac0f92b7fcf 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.fir.kt @@ -1,2 +1,2 @@ // Class constructor parameter CAN be recursively annotated -class RecursivelyAnnotated(@RecursivelyAnnotated(1) val x: Int) \ No newline at end of file +class RecursivelyAnnotated(@RecursivelyAnnotated(1) val x: Int) diff --git a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.fir.kt b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.fir.kt index 3dc7d2d7bd2..ccb3633cc31 100644 --- a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.fir.kt @@ -1,8 +1,8 @@ package test -@BadAnnotation(1) +@BadAnnotation(1) object SomeObject val some = SomeObject -annotation class BadAnnotation(val s: String) \ No newline at end of file +annotation class BadAnnotation(val s: String) diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_after.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_after.fir.kt index e5cdcbffc91..49fab029968 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_after.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_after.fir.kt @@ -11,5 +11,5 @@ enum class MyEnum { A } -@AnnE(Test()) -class Test2 \ No newline at end of file +@AnnE(Test()) +class Test2 diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_before.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_before.fir.kt index 35d43f1e3e4..5992022f709 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_before.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst_before.fir.kt @@ -11,5 +11,5 @@ enum class MyEnum { A } -@AnnE(Test()) -class Test2 \ No newline at end of file +@AnnE(Test()) +class Test2 diff --git a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.fir.kt index 33f552e47e1..949c2da42a4 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.fir.kt @@ -13,7 +13,7 @@ fun foo() { return@l1 103 } - bar @Ann("") { + bar @Ann("") { 104 } } diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.fir.kt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.fir.kt index b2e39f4b44a..ac941a87cd9 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.fir.kt @@ -8,7 +8,7 @@ annotation class Ann(val x: Int = 6) @Ann(1) @Ann(2) @Ann(3) private class A @Ann constructor() { @Ann(x = 5) fun foo() { - 1 + @Ann(1) 1 * @Ann("") 6 + 1 + @Ann(1) 1 * @Ann("") 6 @Ann fun local() {} } diff --git a/compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.fir.kt b/compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.fir.kt index df340589e70..76b97b9a5f2 100644 --- a/compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.fir.kt @@ -2,9 +2,9 @@ import java.lang.annotation.Repeatable -@java.lang.annotation.Repeatable(Annotations::class) annotation class RepAnn +@java.lang.annotation.Repeatable(Annotations::class) annotation class RepAnn -@Repeatable(OtherAnnotations::class) annotation class OtherAnn +@Repeatable(OtherAnnotations::class) annotation class OtherAnn annotation class Annotations(vararg val value: RepAnn) diff --git a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt index f253cd804d0..0555c2e86a0 100644 --- a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt @@ -3,36 +3,36 @@ package test import kotlin.internal.RequireKotlin -@RequireKotlin("") +@RequireKotlin("") fun f01() {} -@RequireKotlin("x") +@RequireKotlin("x") fun f02() {} -@RequireKotlin("1") +@RequireKotlin("1") fun f03() {} -@RequireKotlin("1.0-beta") +@RequireKotlin("1.0-beta") fun f04() {} -@RequireKotlin("1.1.0-dev-1111") +@RequireKotlin("1.1.0-dev-1111") fun f05() {} -@RequireKotlin("1.5.3.7") +@RequireKotlin("1.5.3.7") fun f06() {} -@RequireKotlin("1..0") +@RequireKotlin("1..0") fun f07() {} -@RequireKotlin(" 1.0") +@RequireKotlin(" 1.0") fun f08() {} -@RequireKotlin("1.1") +@RequireKotlin("1.1") fun ok1() {} -@RequireKotlin("1.1.0") +@RequireKotlin("1.1.0") fun ok2() {} -@RequireKotlin("0.0.0") +@RequireKotlin("0.0.0") fun ok3() {} diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-negative.fir.kt b/compiler/testData/diagnostics/tests/annotations/kt1860-negative.fir.kt index 5d5314779f0..c5acecfd484 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-negative.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-negative.fir.kt @@ -1,10 +1,10 @@ // !WITH_NEW_INFERENCE -fun foo(@varargs f : Int) {} +fun foo(@varargs f : Int) {} var bar : Int = 1 - set(@varargs v) {} + set(@varargs v) {} -val x : (Int) -> Int = {@varargs x : Int -> x} +val x : (Int) -> Int = {@varargs x : Int -> x} -class Hello(@varargs args: Any) { -} \ No newline at end of file +class Hello(@varargs args: Any) { +} diff --git a/compiler/testData/diagnostics/tests/annotations/typeParameterAsAnnotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/typeParameterAsAnnotation.fir.kt index cedd6de950f..f070776dbbf 100644 --- a/compiler/testData/diagnostics/tests/annotations/typeParameterAsAnnotation.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/typeParameterAsAnnotation.fir.kt @@ -1,9 +1,9 @@ class Foo { - @T + @T fun foo() = 0 } class Bar { - @T + @T fun foo() = 0 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt b/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt index 060d89e47f1..9e38b3185b2 100644 --- a/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt @@ -1,5 +1,5 @@ -@Ann class A -@Ann class B -@Ann(1) class C -@kotlin.Ann(1) class D -@kotlin.annotation.Ann(1) class E \ No newline at end of file +@Ann class A +@Ann class B +@Ann(1) class C +@kotlin.Ann(1) class D +@kotlin.annotation.Ann(1) class E \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.fir.kt b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.fir.kt index e395835eb6e..0f5d04f6d1d 100644 --- a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.fir.kt +++ b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.fir.kt @@ -34,8 +34,8 @@ fun test6() {} annotation class AnnArray(val a: Array) -@AnnArray(*["/"]) +@AnnArray(*["/"]) fun testArray() {} @Ann1([""]) -fun testVararg() {} \ No newline at end of file +fun testVararg() {} diff --git a/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.fir.kt b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.fir.kt index 4206722ba17..c1adba9e67c 100644 --- a/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.fir.kt @@ -11,6 +11,6 @@ public class A { // FILE: B.kt -class B(private @property:Deprecated val foo: String) : A() { +class B(private @property:Deprecated val foo: String) : A() { override fun getFoo(text: String): String = super.getFoo(text + foo) } diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt index 70c58e281c2..e1ed0ef2e7a 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt @@ -1,7 +1,7 @@ // !CHECK_TYPE -@kotlin.internal.InlineOnly +@kotlin.internal.InlineOnly public inline fun C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this public fun listOf(t: T): List = TODO() @@ -13,4 +13,4 @@ fun usage(c: List) { val cs = c.ifEmpty { listOf("x") } cs checkType { _>() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/localClasses/localAnnotationClass.fir.kt b/compiler/testData/diagnostics/tests/localClasses/localAnnotationClass.fir.kt index 816f17a81b1..6ec90129200 100644 --- a/compiler/testData/diagnostics/tests/localClasses/localAnnotationClass.fir.kt +++ b/compiler/testData/diagnostics/tests/localClasses/localAnnotationClass.fir.kt @@ -3,7 +3,7 @@ fun f() { annotation class Anno - @Anno class Local { + @Anno class Local { annotation class Nested } } diff --git a/compiler/testData/diagnostics/tests/localClasses/localAnnotationClassError.fir.kt b/compiler/testData/diagnostics/tests/localClasses/localAnnotationClassError.fir.kt index 6237efead02..f40d3f357f9 100644 --- a/compiler/testData/diagnostics/tests/localClasses/localAnnotationClassError.fir.kt +++ b/compiler/testData/diagnostics/tests/localClasses/localAnnotationClassError.fir.kt @@ -3,7 +3,7 @@ fun f() { annotation class Anno - @Anno class Local { + @Anno class Local { annotation class Nested } } diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt index 32ff714f8dd..749121c7c27 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt @@ -1,4 +1,4 @@ -@myAnnotation public +@myAnnotation public package illegal_modifiers abstract class A() { diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/annotationConstructor.fir.kt b/compiler/testData/diagnostics/tests/objects/kt21515/annotationConstructor.fir.kt index f4f4711dc09..77f471615b6 100644 --- a/compiler/testData/diagnostics/tests/objects/kt21515/annotationConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/kt21515/annotationConstructor.fir.kt @@ -8,6 +8,6 @@ open class Base { class Derived : Base() { - @Foo + @Foo fun foo() = 42 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt b/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt index 9704b7c99f6..d7ce81b200c 100644 --- a/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt +++ b/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt @@ -17,11 +17,11 @@ class C1 // FILE: 2.kt package pp -@A(foo) +@A(foo) fun f2() {} -@A(foo) +@A(foo) val p2 = "" -@A(foo) +@A(foo) class C2 diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.fir.kt index 126437ad8ae..b36ed84abaf 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.fir.kt @@ -5,8 +5,8 @@ annotation class Ann2(val x: Int) class A { @Ann1 constructor() - @Ann2 + @Ann2 constructor(x1: Int) @Ann2(2) constructor(x1: Int, x2: Int) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_3.fir.kt b/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_3.fir.kt index fb04b9988b0..759bac05a60 100644 --- a/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_3.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_3.fir.kt @@ -31,6 +31,6 @@ fun test_ann(s: String, arr: Array) { @Ann("", x = 1) foo() - @Ann(s = "", x = 1) + @Ann(s = "", x = 1) foo() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_4.fir.kt b/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_4.fir.kt index 971e060e747..585dfa8c7d9 100644 --- a/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_4.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/assignArrayToVararagInNamedForm_1_4.fir.kt @@ -31,6 +31,6 @@ fun test_ann(s: String, arr: Array) { @Ann("", x = 1) foo() - @Ann(s = "", x = 1) + @Ann(s = "", x = 1) foo() } diff --git a/compiler/testData/diagnostics/tests/varargs/assigningArraysToVarargsInAnnotations.fir.kt b/compiler/testData/diagnostics/tests/varargs/assigningArraysToVarargsInAnnotations.fir.kt index 115ec1bc83e..93696283bf2 100644 --- a/compiler/testData/diagnostics/tests/varargs/assigningArraysToVarargsInAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/assigningArraysToVarargsInAnnotations.fir.kt @@ -15,10 +15,10 @@ annotation class Ann(vararg val s: String) @Ann(s = arrayOf()) fun test1() {} -@Ann(s = intArrayOf()) +@Ann(s = intArrayOf()) fun test2() {} -@Ann(s = arrayOf(1)) +@Ann(s = arrayOf(1)) fun test3() {} @Ann("value1", "value2") @@ -43,4 +43,4 @@ annotation class IntAnn(vararg val i: Int) fun foo1() {} @IntAnn(i = intArrayOf(0)) -fun foo2() {} \ No newline at end of file +fun foo2() {} diff --git a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_after.fir.kt b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_after.fir.kt index 80eef870bb9..1e3e7c74303 100644 --- a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_after.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_after.fir.kt @@ -11,7 +11,7 @@ annotation class Ann(vararg val s: String) -@Ann(s = "value") +@Ann(s = "value") fun test1() {} @Ann(s = *arrayOf("value")) @@ -20,11 +20,11 @@ fun test2() {} @Ann(s = *["value"]) fun test3() {} -@JavaAnn(value = "value") +@JavaAnn(value = "value") fun test4() {} @JavaAnn("value", path = arrayOf("path")) fun test5() {} @JavaAnn("value", path = ["path"]) -fun test6() {} \ No newline at end of file +fun test6() {} diff --git a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_before.fir.kt b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_before.fir.kt index b08c422c1cb..a79b81feb50 100644 --- a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_before.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation_before.fir.kt @@ -11,7 +11,7 @@ annotation class Ann(vararg val s: String) -@Ann(s = "value") +@Ann(s = "value") fun test1() {} @Ann(s = *arrayOf("value")) @@ -20,11 +20,11 @@ fun test2() {} @Ann(s = *["value"]) fun test3() {} -@JavaAnn(value = "value") +@JavaAnn(value = "value") fun test4() {} @JavaAnn("value", path = arrayOf("path")) fun test5() {} @JavaAnn("value", path = ["path"]) -fun test6() {} \ No newline at end of file +fun test6() {} diff --git a/compiler/testData/diagnostics/tests/varargs/noAssigningArraysToVarargsFeature.fir.kt b/compiler/testData/diagnostics/tests/varargs/noAssigningArraysToVarargsFeature.fir.kt index 0847abdf8e8..cc3ec4cefa5 100644 --- a/compiler/testData/diagnostics/tests/varargs/noAssigningArraysToVarargsFeature.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/noAssigningArraysToVarargsFeature.fir.kt @@ -15,10 +15,10 @@ annotation class Ann(vararg val s: String) @Ann(s = arrayOf()) fun test1() {} -@Ann(s = intArrayOf()) +@Ann(s = intArrayOf()) fun test2() {} -@Ann(s = arrayOf(1)) +@Ann(s = arrayOf(1)) fun test3() {} @Ann(s = ["value"]) @@ -43,7 +43,7 @@ fun foo2() {} fun foo(vararg i: Int) {} -@Ann(s = "value") +@Ann(s = "value") fun dep1() { foo(i = 1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/varargs/prohibitAssigningSingleElementsInNamedForm.fir.kt b/compiler/testData/diagnostics/tests/varargs/prohibitAssigningSingleElementsInNamedForm.fir.kt index be0d598dc42..2b3e3fd2806 100644 --- a/compiler/testData/diagnostics/tests/varargs/prohibitAssigningSingleElementsInNamedForm.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/prohibitAssigningSingleElementsInNamedForm.fir.kt @@ -4,7 +4,7 @@ annotation class Anno1(vararg val s: String) annotation class Anno2(vararg val i: Int) -@Anno1(s = "foo") +@Anno1(s = "foo") @Anno2(i = *intArrayOf(1)) fun f1() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.fir.kt index 7ec64f27b78..6ce866b31de 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.fir.kt @@ -12,12 +12,12 @@ public @interface A { @A(*arrayOf("5", "6"), "7", y = 3) fun test3() {} -@A("1", "2", "3", x = String::class, y = 4) fun test4() {} +@A("1", "2", "3", x = String::class, y = 4) fun test4() {} @A("4", y = 5) fun test5() {} -@A(*arrayOf("5", "6"), "7", x = Any::class, y = 6) fun test6() {} +@A(*arrayOf("5", "6"), "7", x = Any::class, y = 6) fun test6() {} @A(y = 7) fun test7() {} -@A("8", "9", "10") fun test8() {} +@A("8", "9", "10") fun test8() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt index 3e85d5f48e6..65d5f8d36d7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt @@ -15,16 +15,16 @@ public @interface A { @A(*arrayOf("5", "6"), "7") fun test3() {} -@A("1", "2", "3", x = String::class) fun test4() {} +@A("1", "2", "3", x = String::class) fun test4() {} @A("4", y = 2) fun test5() {} -@A(*arrayOf("5", "6"), "7", x = Any::class, y = 3) fun test6() {} +@A(*arrayOf("5", "6"), "7", x = Any::class, y = 3) fun test6() {} @A() fun test7() {} @A fun test8() {} -@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {} -@A(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {} -@A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {} +@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {} +@A(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {} +@A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.fir.kt index 91397e85f6e..4d9dec1b658 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.fir.kt @@ -6,6 +6,6 @@ public @interface A { } // FILE: b.kt -@A(*arrayOf(1, "b")) +@A(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.fir.kt index f0d690e8101..c2424ad10b4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.fir.kt @@ -2,6 +2,6 @@ annotation class B(vararg val args: String) -@B(*arrayOf(1, "b")) +@B(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.fir.kt index 12ce9ee1123..cc3cdfacdc1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.fir.kt @@ -1,27 +1,27 @@ // !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE // FILE: b.kt -@file:JvmPackageName("") +@file:JvmPackageName("") package b fun b() {} // FILE: c.kt -@file:JvmPackageName("invalid-fq-name") +@file:JvmPackageName("invalid-fq-name") package c fun c() {} // FILE: d.kt -@file:JvmPackageName("d") +@file:JvmPackageName("d") package d class D fun d() {} // FILE: e.kt -@file:JvmPackageName(42) +@file:JvmPackageName(42) package e fun e() {} // FILE: f.kt -@file:JvmPackageName(f) +@file:JvmPackageName(f) package f const val name = "f" diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.fir.kt index c9bcbb129f4..a1b34642fdd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.fir.kt @@ -14,7 +14,7 @@ class MyClass1 @Ann1(arrayOf(Any::class)) class MyClass1a -@Ann1(arrayOf(B1::class)) +@Ann1(arrayOf(B1::class)) class MyClass2 annotation class Ann2(val arg: Array>) @@ -25,5 +25,5 @@ class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.fir.kt index 4c8f7fa4288..11bce1bb6b5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.fir.kt @@ -11,7 +11,7 @@ annotation class Ann1(val arg: Array>) @Ann1(arrayOf(A::class)) class MyClass1 -@Ann1(arrayOf(Any::class)) +@Ann1(arrayOf(Any::class)) class MyClass1a @Ann1(arrayOf(B1::class)) @@ -19,11 +19,11 @@ class MyClass2 annotation class Ann2(val arg: Array>) -@Ann2(arrayOf(A::class)) +@Ann2(arrayOf(A::class)) class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.fir.kt index 0a6c837b9db..f73ba7764ee 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.fir.kt @@ -12,7 +12,7 @@ class MyClass1 @Ann1(Any::class) class MyClass1a -@Ann1(B1::class) +@Ann1(B1::class) class MyClass2 annotation class Ann2(val arg: KClass) @@ -23,5 +23,5 @@ class MyClass3 @Ann2(B1::class) class MyClass4 -@Ann2(B2::class) +@Ann2(B2::class) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.fir.kt index c8f3653fa84..64ecb487ef4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.fir.kt @@ -9,7 +9,7 @@ annotation class Ann1(val arg: KClass) @Ann1(A::class) class MyClass1 -@Ann1(Any::class) +@Ann1(Any::class) class MyClass1a @Ann1(B1::class) @@ -17,11 +17,11 @@ class MyClass2 annotation class Ann2(val arg: KClass) -@Ann2(A::class) +@Ann2(A::class) class MyClass3 @Ann2(B1::class) class MyClass4 -@Ann2(B2::class) +@Ann2(B2::class) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.fir.kt index d29699497ad..de094f1cce6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.fir.kt @@ -8,15 +8,15 @@ annotation class Ann1(val arg: KClass) @Ann1(A::class) class MyClass1 -@Ann1(Any::class) +@Ann1(Any::class) class MyClass1a -@Ann1(B::class) +@Ann1(B::class) class MyClass2 annotation class Ann2(val arg: KClass) -@Ann2(A::class) +@Ann2(A::class) class MyClass3 @Ann2(B::class) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.fir.kt index 170d4221995..f3cd8e7f854 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.fir.kt @@ -6,6 +6,6 @@ public @interface A { } // FILE: b.kt -@A(false, +@A(false, 1.0, -false, 1, 2) fun foo1() {} +false, 1, 2) fun foo1() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.fir.kt index 3b5db4e2084..412093c90fe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.fir.kt @@ -6,8 +6,8 @@ public @interface A { } // FILE: b.kt -@A(false, +@A(false, 1.0, -false) fun foo1() {} +false) fun foo1() {} -@A(2.0, x = true, b = 2.0) fun foo2() {} +@A(2.0, x = true, b = 2.0) fun foo2() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/wasExperimental.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/wasExperimental.fir.kt index 97b827d82f5..671a8582a04 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/wasExperimental.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/wasExperimental.fir.kt @@ -10,19 +10,19 @@ fun newPublishedFun() {} annotation class Marker @SinceKotlin("1.4") -@WasExperimental(Marker::class) +@WasExperimental(Marker::class) fun newFunExperimentalInThePast() {} @SinceKotlin("1.4") -@WasExperimental(Marker::class) +@WasExperimental(Marker::class) val newValExperimentalInThePast = "" @SinceKotlin("1.4") -@WasExperimental(Marker::class) +@WasExperimental(Marker::class) class NewClassExperimentalInThePast @SinceKotlin("1.4") -@WasExperimental(Marker::class) +@WasExperimental(Marker::class) typealias TypeAliasToNewClass = NewClassExperimentalInThePast diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt index 8447667a390..6458d2f9600 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt @@ -1,6 +1,6 @@ class Foo { @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - @kotlin.internal.LowPriorityInOverloadResolution + @kotlin.internal.LowPriorityInOverloadResolution val test: Bar = Bar() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt index 3b9dab21dfb..1258e86b774 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?> +fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?> Map.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO() fun test() { @@ -14,4 +14,4 @@ fun test() { r2 map.getOrDefault_Exact("y", "string") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt index 4371e57f002..c29c1d35cdb 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt @@ -5,7 +5,7 @@ interface Parent object ChildA : Parent object ChildB : Parent -fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {} +fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {} fun test() { select(ChildA, ChildB) // should be error diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt index 4e2e8e59758..67580ab4a6e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt @@ -7,17 +7,17 @@ class CX : Base() class CY : Base() @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {} +fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {} @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {} +fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {} @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {} +fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {} fun usage(x: CX, y: CY) { foo(x, y) // expected err, got err fooA(x, y) // expected err, got ok fooB(x, y) // expected err, got ok -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt new file mode 100644 index 00000000000..12f5b36ec17 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +annotation class Anno + +fun test(a: List>) { + strictSelect(a, emptyList().map { it.annotationClass.java }) +} + +fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt index 80947f205a6..21384611c0a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !LANGUAGE: +NewInference // !DIAGNOSTICS: -UNUSED_PARAMETER @@ -10,4 +9,4 @@ fun test(a: List>) { strictSelect(a, emptyList().map { it.annotationClass.java }) } -fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO() \ No newline at end of file +fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt index 9bd466ea712..71be470264b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt @@ -3,7 +3,7 @@ @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") -@kotlin.internal.LowPriorityInOverloadResolution +@kotlin.internal.LowPriorityInOverloadResolution public fun Iterable.contains1(element: T): Int = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @@ -13,4 +13,4 @@ public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boole fun test() { val a: Boolean = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt new file mode 100644 index 00000000000..5566febce69 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: TestBase.java + +public class TestBase { } + +// FILE: Test.java + +public class Test extends TestBase { } + +// FILE: main.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K> TestBase.foo(key: K) = null +fun foo(result: Test<*>) { + result.foo("sd") // Type inference failed (NI), OK in OI +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt index ec2767ec64e..9885741ed5f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !LANGUAGE: +NewInference // !DIAGNOSTICS: -UNUSED_PARAMETER @@ -16,4 +15,4 @@ public class Test extends TestBase { } fun <@kotlin.internal.OnlyInputTypes K> TestBase.foo(key: K) = null fun foo(result: Test<*>) { result.foo("sd") // Type inference failed (NI), OK in OI -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt new file mode 100644 index 00000000000..60daaa84ff5 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt @@ -0,0 +1,24 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +interface IFace + +fun <@kotlin.internal.OnlyInputTypes K, V> IFace.get(key: K): V? = TODO() +fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg + +interface InvBase +class DerivedInv : InvBase +class InvRecursive> + +fun test1(argument: InvRecursive<*>, receiver: IFace, Any>) { + receiver.get(argument) +} + +fun test2(arg: InvRecursive) { + id(arg) +} + +fun test3(arg: InvRecursive) { + id(arg) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt index df166ba2065..fcad07fe37a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt index 9e27a41bc2d..9ff248d429d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt @@ -3,7 +3,7 @@ // !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! class In diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index aa469919288..f24106e995a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -4,19 +4,19 @@ @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") -@kotlin.internal.LowPriorityInOverloadResolution +@kotlin.internal.LowPriorityInOverloadResolution public fun Iterable.contains1(element: T): Int = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @JvmName("getAny") -@kotlin.internal.LowPriorityInOverloadResolution +@kotlin.internal.LowPriorityInOverloadResolution public fun Map.get1(key: Any?): Int = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! +public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { val a: Int = listOf(1).contains1("") @@ -24,4 +24,4 @@ fun test(map: Map) { val c: String? = map.get1("") val d: String? = map.get1(1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt index d421514ddbb..3ae41579f36 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt @@ -5,13 +5,13 @@ class Inv @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyOut(e: K) {} +fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyOut(e: K) {} @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes K : Number> Inv.onlyOutUB(e: K) {} +fun <@kotlin.internal.OnlyInputTypes K : Number> Inv.onlyOutUB(e: K) {} @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyIn(e: K) {} +fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyIn(e: K) {} fun test( invStar: Inv<*>, @@ -71,4 +71,4 @@ class Test5 { } field = value } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt new file mode 100644 index 00000000000..97ffba5e302 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt @@ -0,0 +1,19 @@ +//!DIAGNOSTICS: -UNUSED_PARAMETER + +//FILE:Foo.java + +public class Foo { + public static String foo() { + return null; + } +} + +//FILE:Bar.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} + +fun test() { + assertEquals1(null, Foo.foo()) + assertEquals1("", Foo.foo()) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt index 71054d75095..6e534cfe513 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL //!DIAGNOSTICS: -UNUSED_PARAMETER //FILE:Foo.java @@ -17,4 +16,4 @@ fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} fun test() { assertEquals1(null, Foo.foo()) assertEquals1("", Foo.foo()) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt index 70d291aa3d3..9171eea3e48 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt @@ -4,10 +4,10 @@ // Issue: KT-26698 @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.foo(element: T): T = null!! +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.foo(element: T): T = null!! class Inv class Inv2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt index 5b1fe7bb7d9..f6baab762de 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt @@ -16,8 +16,8 @@ class InB(v: C) class Out(val v: O) class OutB(val v: O) -fun <@OnlyInputTypes M> strictId(arg: M): M = arg -fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1 +fun <@OnlyInputTypes M> strictId(arg: M): M = arg +fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1 fun testOK(first: First, bound: Bound, second: Second) { strictId(Inv(15)) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt index 076ccc56655..d7b5b2c573b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt @@ -10,4 +10,4 @@ fun foo(i: Inv, o: Out) { bar(i, o) } -fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv, o: Out): K = TODO() +fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv, o: Out): K = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt index 02c6645fc44..710cf6324a2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt @@ -2,7 +2,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO() +fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO() interface Common class First : Common diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt index e8694c7c4f9..f4db443205d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt @@ -3,7 +3,7 @@ // !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} +fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} open class A class B: A() @@ -19,8 +19,8 @@ fun test1(a: A, b: B, c: C) { } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {} +public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {} fun test() { expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.fir.kt new file mode 100644 index 00000000000..2e7662ec2fe --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.fir.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER -NULLABLE_INLINE_PARAMETER + +@kotlin.internal.InlineOnly +inline fun test() { + +} + +@kotlin.internal.InlineOnly +inline fun test3(noinline s : (Int) -> Int) { + +} + +@kotlin.internal.InlineOnly +inline fun test4(noinline s : Int.() -> Int) { + +} + +@kotlin.internal.InlineOnly +inline fun Function1?.test5() { + +} + +@kotlin.internal.InlineOnly +inline fun Function1?.test6() { + +} + +@kotlin.internal.InlineOnly +inline fun test2(s : ((Int) -> Int)?) { + +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt index 8752a329887..bbff0b42bd3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER -NULLABLE_INLINE_PARAMETER @kotlin.internal.InlineOnly @@ -29,4 +28,4 @@ inline fun Function1?.test6() { @kotlin.internal.InlineOnly inline fun test2(s : ((Int) -> Int)?) { -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt new file mode 100644 index 00000000000..2f6e572ab4d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +inline fun @kotlin.internal.PureReifiable T> foo(x: T) {} + +fun test() { + foo>(listOf("")) + foo(listOf("")) + + foo>(arrayOf("")) + foo(arrayOf("")) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt index 203678eff51..648e86cbe34 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.fir.kt index c1ce1e4d6b1..36209e35b10 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.fir.kt @@ -1,8 +1,8 @@ -@JvmName() +@JvmName() fun foo() {} -@JvmName(42) +@JvmName(42) fun bar() {} -@JvmName("a", "b") +@JvmName("a", "b") fun baz() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt index 2a3392183b7..fd2ce8d10e4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt @@ -8,11 +8,11 @@ package b import a.A @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.HidesMembers +@kotlin.internal.HidesMembers fun A.forEach(i: Int) = i @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.HidesMembers +@kotlin.internal.HidesMembers fun A.forEach(s: String) {} @@ -28,11 +28,11 @@ class A { } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.HidesMembers +@kotlin.internal.HidesMembers fun A.forEach() = "" @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.HidesMembers +@kotlin.internal.HidesMembers fun A.forEach(s: String) {} fun test(a: A) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt index dc9fba5def3..41027b555cd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt @@ -8,12 +8,12 @@ class A { } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@kotlin.internal.HidesMembers +@kotlin.internal.HidesMembers fun A.forEach(i: Int) = i class B { @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - @kotlin.internal.HidesMembers + @kotlin.internal.HidesMembers fun A.forEach() = this@B fun test(a: A) { @@ -27,11 +27,11 @@ class B { fun test2(a: A) { @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - @kotlin.internal.HidesMembers + @kotlin.internal.HidesMembers fun A.forEach() = "" @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - @kotlin.internal.HidesMembers + @kotlin.internal.HidesMembers fun A.forEach(i: Int) = "" a.forEach() checkType { _() } @@ -41,4 +41,4 @@ fun test2(a: A) { forEach() checkType { _() } forEach(1) } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.fir.txt b/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.fir.txt deleted file mode 100644 index 173cb184e09..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.fir.txt +++ /dev/null @@ -1,7 +0,0 @@ -FILE fqName: fileName:/javaAnnotation.kt - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt b/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt index 53e4ca86bd0..984f836d08a 100644 --- a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt +++ b/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt @@ -1,4 +1,5 @@ // FILE: JavaAnn.java +// FIR_IDENTICAL import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -9,6 +10,7 @@ import java.lang.annotation.RetentionPolicy; } // FILE: javaAnnotation.kt +// FIR_IDENTICAL @JavaAnn fun test1() {} @JavaAnn(value="abc", i=123) fun test2() {}