diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt index 12b69a03be5..26560357b02 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -1419,6 +1419,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR) { firDiagnostic -> + TypeInferenceOnlyInputTypesErrorImpl( + firSymbolBuilder.classifierBuilder.buildTypeParameterSymbol(firDiagnostic.a), + firDiagnostic as KtPsiDiagnostic, + token, + ) + } add(FirErrors.THROWABLE_TYPE_MISMATCH) { firDiagnostic -> ThrowableTypeMismatchImpl( firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a), diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt index a66c72857e5..b5d721ff982 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt @@ -1021,6 +1021,11 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val isMismatchDueToNullability: Boolean } + abstract class TypeInferenceOnlyInputTypesError : KtFirDiagnostic() { + override val diagnosticClass get() = TypeInferenceOnlyInputTypesError::class + abstract val typeParameter: KtTypeParameterSymbol + } + abstract class ThrowableTypeMismatch : KtFirDiagnostic() { override val diagnosticClass get() = ThrowableTypeMismatch::class abstract val actualType: KtType diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 056871c51ab..b09fc0d7a11 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -1224,6 +1224,12 @@ internal class TypeMismatchImpl( override val token: KtLifetimeToken, ) : KtFirDiagnostic.TypeMismatch(), KtAbstractFirDiagnostic +internal class TypeInferenceOnlyInputTypesErrorImpl( + override val typeParameter: KtTypeParameterSymbol, + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.TypeInferenceOnlyInputTypesError(), KtAbstractFirDiagnostic + internal class ThrowableTypeMismatchImpl( override val actualType: KtType, override val isMismatchDueToNullability: Boolean, diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 92f3751fb55..a77d2e3abcb 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -449,6 +449,10 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") { parameter("isMismatchDueToNullability") } + val TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR by error() { + parameter("typeParameter") + } + val THROWABLE_TYPE_MISMATCH by error { parameter("actualType") parameter("isMismatchDueToNullability") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 6f17edac54f..756ed97df78 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -330,6 +330,7 @@ object FirErrors { val NONE_APPLICABLE by error1>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val INAPPLICABLE_CANDIDATE by error1>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val TYPE_MISMATCH by error3() + val TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR by error1() val THROWABLE_TYPE_MISMATCH by error2() val CONDITION_TYPE_MISMATCH by error2() val ARGUMENT_TYPE_MISMATCH by error3() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt index 694a5c00124..d5c66bc07fa 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt @@ -134,7 +134,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_CONSTRUCTO import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_GENERIC_UPPER_BOUND import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_INHERITANCE_HIERARCHY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DANGEROUS_CHARACTERS -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DATA_CLASS_NOT_PROPERTY_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DATA_CLASS_OVERRIDE_CONFLICT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DATA_CLASS_VARARG_PARAMETER @@ -257,6 +256,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCORRECT_CHARACT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCORRECT_LEFT_COMPONENT_OF_INTERSECTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCORRECT_RIGHT_COMPONENT_OF_INTERSECTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INC_DEC_SHOULD_NOT_RETURN_UNIT +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_UNSUCCESSFUL_FORK import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION @@ -499,6 +499,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPECHECKER_HAS_R import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_ARGUMENTS_NOT_ALLOWED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_CANT_BE_USED_FOR_CONST_VAL +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_MISMATCH import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TYPE_PARAMETERS_IN_ENUM @@ -1010,6 +1011,11 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() { ) map.put(TYPE_MISMATCH, "Type mismatch: inferred type is {1} but {0} was expected", TO_STRING, TO_STRING, NOT_RENDERED) + map.put( + TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR, + "Type inference failed. The value of the type parameter {0} should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.", + SYMBOL + ) map.put(THROWABLE_TYPE_MISMATCH, "Throwable type mismatch: actual type is {0}", TO_STRING, NOT_RENDERED) map.put(CONDITION_TYPE_MISMATCH, "Condition type mismatch: inferred type is {0} but Boolean was expected", TO_STRING, NOT_RENDERED) map.put( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index 11978b2be5e..dec024f3d13 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -442,6 +442,13 @@ private fun ConstraintSystemError.toDiagnostic( ) } + is OnlyInputTypesDiagnostic -> { + FirErrors.TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR.createOn( + source, + (typeVariable as ConeTypeParameterBasedTypeVariable).typeParameterSymbol + ) + } + else -> null } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt index 77ac98b7084..74ee6d954ed 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt @@ -16,6 +16,8 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.createFunctionalType import org.jetbrains.kotlin.fir.resolve.dfa.unwrapSmartcastExpression import org.jetbrains.kotlin.fir.resolve.fullyExpandedType +import org.jetbrains.kotlin.fir.resolve.inference.model.ConeArgumentConstraintPosition +import org.jetbrains.kotlin.fir.resolve.inference.model.ConeReceiverConstraintPosition import org.jetbrains.kotlin.fir.resolve.inference.preprocessCallableReference import org.jetbrains.kotlin.fir.resolve.inference.preprocessLambdaArgument import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator @@ -32,6 +34,7 @@ import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible import org.jetbrains.kotlin.resolve.calls.inference.components.VariableFixationFinder +import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.model.CaptureStatus @@ -251,7 +254,7 @@ fun Candidate.resolvePlainArgumentType( isDispatch: Boolean, useNullableArgumentType: Boolean = false ) { - val position = SimpleConstraintSystemConstraintPosition //TODO + val position = if (isReceiver) ConeReceiverConstraintPosition(argument) else ConeArgumentConstraintPosition(argument) val session = context.session val capturedType = prepareCapturedType(argumentType, context) @@ -348,7 +351,7 @@ private fun checkApplicabilityForArgumentType( argument: FirExpression, argumentTypeBeforeCapturing: ConeKotlinType, expectedType: ConeKotlinType?, - position: SimpleConstraintSystemConstraintPosition, + position: ConstraintPosition, isReceiver: Boolean, isDispatch: Boolean, sink: CheckerSink, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt index 110ddb0c300..12bcbbf9769 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.resolve.inference.model.ConeFixVariableConstrain import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.fir.types.coneTypeSafe +import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemUtilContext import org.jetbrains.kotlin.resolve.calls.inference.components.PostponedArgumentInputTypesResolver import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition @@ -27,8 +28,8 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext { } override fun TypeVariableMarker.hasOnlyInputTypesAttribute(): Boolean { - // TODO - return false + if (this !is ConeTypeParameterBasedTypeVariable) return false + return typeParameterSymbol.resolvedAnnotationClassIds.any { it == StandardClassIds.Annotations.OnlyInputTypes } } override fun KotlinTypeMarker.unCapture(): KotlinTypeMarker { diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/inference/model/FirConstraintPositionAndErrors.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/inference/model/FirConstraintPositionAndErrors.kt index cabc47d18b3..0a4f323213d 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/inference/model/FirConstraintPositionAndErrors.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/inference/model/FirConstraintPositionAndErrors.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.inference.model import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction +import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.resolve.calls.inference.model.* import org.jetbrains.kotlin.types.model.TypeVariableMarker @@ -31,4 +32,6 @@ class ConeLambdaArgumentConstraintPosition( class ConeBuilderInferenceSubstitutionConstraintPosition(initialConstraint: InitialConstraint) : - BuilderInferenceSubstitutionConstraintPosition(null, initialConstraint) // TODO \ No newline at end of file + BuilderInferenceSubstitutionConstraintPosition(null, initialConstraint) // TODO + +class ConeReceiverConstraintPosition(receiver: FirExpression) : ReceiverConstraintPosition(receiver) diff --git a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt index 054b109ac03..088e7d7854b 100644 --- a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt +++ b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR, JS_IR +// FIR status: Disabling of StrictOnlyInputTypesChecks is not supported by FIR // WITH_STDLIB // !LANGUAGE: -StrictOnlyInputTypesChecks @@ -79,4 +81,4 @@ fun box(): String { poll81() poll91() return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt index 054b109ac03..088e7d7854b 100644 --- a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt +++ b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR, JS_IR +// FIR status: Disabling of StrictOnlyInputTypesChecks is not supported by FIR // WITH_STDLIB // !LANGUAGE: -StrictOnlyInputTypesChecks @@ -79,4 +81,4 @@ fun box(): String { poll81() poll91() return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt b/compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt index 097a06b25c6..f9975531ab6 100644 --- a/compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt +++ b/compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR, JS_IR +// FIR status: Disabling of StrictOnlyInputTypesChecks is not supported by FIR // WITH_STDLIB // SKIP_TXT // !LANGUAGE: -StrictOnlyInputTypesChecks diff --git a/compiler/testData/codegen/box/operatorConventions/kt39880.kt b/compiler/testData/codegen/box/operatorConventions/kt39880.kt index b93137a5ae2..299b9cdd12a 100644 --- a/compiler/testData/codegen/box/operatorConventions/kt39880.kt +++ b/compiler/testData/codegen/box/operatorConventions/kt39880.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR, JS_IR +// FIR status: Disabling of StrictOnlyInputTypesChecks is not supported by FIR // WITH_STDLIB // !LANGUAGE: -StrictOnlyInputTypesChecks diff --git a/compiler/testData/codegen/box/operatorConventions/kt42722.kt b/compiler/testData/codegen/box/operatorConventions/kt42722.kt index c8773932f51..e96689f0526 100644 --- a/compiler/testData/codegen/box/operatorConventions/kt42722.kt +++ b/compiler/testData/codegen/box/operatorConventions/kt42722.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR, JS_IR +// FIR status: Disabling of StrictOnlyInputTypesChecks is not supported by FIR // WITH_STDLIB // !LANGUAGE: -StrictOnlyInputTypesChecks diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt index 80704d628da..ec9657bb98a 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt @@ -444,7 +444,7 @@ fun poll8(): Flow { fun poll81(): Flow { return flow { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } } @@ -458,7 +458,7 @@ fun poll82(): Flow { fun poll83(): Flow { return flow { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } } @@ -486,7 +486,7 @@ fun poll86(): Flow { fun poll87(): Flow { return flow { - val inv = ::Foo7 in setOf(foo7()) + val inv = ::Foo7 in setOf(foo7()) inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.fir.kt index 586d14baba0..a0ed075eff7 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.fir.kt @@ -57,14 +57,14 @@ fun poll75(): Flow { fun poll81(): Flow { return flow { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } } fun poll83(): Flow { return flow { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.fir.kt index 33695387e0f..27434b53021 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.fir.kt @@ -22,14 +22,14 @@ class Flow(private val block: suspend FlowCollector.() -> Unit) fun poll81(): Flow { return flow { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } } fun poll83(): Flow { return flow { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt index 87ee7c64135..d231208f314 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt @@ -446,7 +446,7 @@ fun poll8(): Flow { fun poll81(): Flow { return flow { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } } @@ -460,7 +460,7 @@ fun poll82(): Flow { fun poll83(): Flow { return flow { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } } @@ -488,7 +488,7 @@ fun poll86(): Flow { fun poll87(): Flow { return flow { - val inv = ::Foo7 in setOf(foo7()) + val inv = ::Foo7 in setOf(foo7()) inv } } diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index 7e06083c8ca..8061d01ede8 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -279,7 +279,7 @@ fun poll8() { } fun poll81() { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } @@ -309,7 +309,7 @@ fun poll86() { } fun poll87() { - val inv = ::Foo7 in setOf(foo7()) + val inv = ::Foo7 in setOf(foo7()) inv } diff --git a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.fir.kt deleted file mode 100644 index 77716460e9d..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.fir.kt +++ /dev/null @@ -1,20 +0,0 @@ -// See also KT-10386 -interface A -class B : A -fun foo1(list: List, arg: B?): Boolean { - // Type mismatch - return arg in list // resolved to extension -} -fun foo2(list: List, arg: B?): Boolean { - // FAKE: no cast needed - return arg as A? in list -} -fun foo3(list: List, arg: B?): Boolean { - // No warning but KNPE risk - return arg!! in list -} -// But -fun foo4(list: List, arg: B): Boolean { - // Ok - return arg in list -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt index 221495d1912..07d0f59435c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // See also KT-10386 interface A class B : A diff --git a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.fir.kt deleted file mode 100644 index 0f699920a13..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.fir.kt +++ /dev/null @@ -1,29 +0,0 @@ - -import java.util.* -fun foo() { - val al = ArrayList() - al.size - al.contains(1) - al.contains("") - - al.remove("") - al.removeAt(1) - - val hs = HashSet() - hs.size - hs.contains(1) - hs.contains("") - - hs.remove("") - - - val hm = HashMap() - hm.size - hm.containsKey(1) - hm.containsKey("") - - hm[1] - hm[""] - - hm.remove("") -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt index f987d7b36ae..80bef83b0fe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import java.util.* fun foo() { val al = ArrayList() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt deleted file mode 100644 index 25ce8b26d85..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER - -interface Parent -object ChildA : Parent -object ChildB : Parent - -fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {} - -fun test() { - select(ChildA, ChildB) // should be error - select(ChildA, ChildB) // should be ok -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt index ee34ba979e8..017fdc63479 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER interface Parent diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt deleted file mode 100644 index 75964e9c205..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE - -open class Base() -class CX : Base() -class CY : Base() - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -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) {} - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -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 -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt index b12d0f58aad..1b803bbd500 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE open class Base() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.fir.kt deleted file mode 100644 index b2dfcf0cf62..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -// ISSUE: KT-29307 - -fun test_1(map: Map) { - val x = map[42] // OK -} - -open class A - -class B : A() - -fun test_2(map: Map) { - val x = map[42] -} - -fun test_3(m: Map<*, String>) { - val x = m[42] // should be ok -} - -fun test_4(m: Map) { - val x = m.get(42) // should be ok -} - -fun test_5(map: Map, a: A) { - map.get(a) -} - -fun test_6(map: Map, b: B) { - map.get(b) -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt index 5f6d8e12478..589102e0f48 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE // ISSUE: KT-29307 diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt deleted file mode 100644 index 9c3bcc87af9..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt +++ /dev/null @@ -1,46 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! - -class In - -class Out - -class Inv - -fun test_1(list: List>, x: In, y: In, z: In) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} - -fun test_2(list: List>, x: In, y: In, z: In) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} - -fun test_3(list: List>, x: Out, y: Out, z: Out) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} - -fun test_4(list: List>, x: Out, y: Out, z: Out) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} - -fun test_5(list: List>, x: Inv, y: Inv, z: Inv) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} - -fun test_6(list: List>, x: Inv, y: Inv, z: Inv) { - list.contains1(x) - list.contains1(y) - list.contains1(z) -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt index 6802cdfd797..8fa1eace4a2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index f5e6dd99a31..74cbe57c379 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -17,9 +17,9 @@ public fun Map.get1(key: Any?): Int = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { - val a: Int = listOf(1).contains1("") + val a: Int = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) - val c: String? = map.get1("") + val c: String? = map.get1("") val d: String? = map.get1(1) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt deleted file mode 100644 index 1e66a7a7ae4..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt +++ /dev/null @@ -1,112 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// Issue: KT-26698 - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -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!! - -class Inv -class Inv2 - -class In -class Out - -// ------------------------------------------------------- - -fun test_0(x: Inv2, list: List>) { - list.foo(x) -} - -// ------------------------- Inv ------------------------- - -fun test_1(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_2(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_3(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_4(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_5(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_6(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_7(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_8(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_9(x: Inv, list: List>) { - list.contains1(x) -} - -// ------------------------- In ------------------------- - -fun test_11(x: In, list: List>) { - list.contains1(x) -} - -fun test_12(x: In, list: List>) { - list.contains1(x) -} - -fun test_13(x: In, list: List>) { - list.contains1(x) -} - -// ------------------------- Out ------------------------- - -fun test_21(x: Out, list: List>) { - list.contains1(x) -} - -fun test_22(x: Out, list: List>) { - list.contains1(x) -} - -fun test_23(x: Out, list: List>) { - list.contains1(x) -} - -// -------------------------------------------------------- - -fun test_31(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_32(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_33(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_34(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_35(x: Inv, list: List>) { - list.contains1(x) -} - -fun test_36(x: Inv, list: List>) { - list.contains1(x) -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt index 3cab312337d..6e1b0c55372 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // Issue: KT-26698 diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt index 478d54a8285..1122f6a421f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt @@ -43,11 +43,11 @@ fun testOK(first: First, bound: Bound, second: Second) { } fun testFail(first: First, bound: Bound, second: Second) { - strictSelect(InvB(first), InvB(bound)) - strictSelect(Inv(first), Inv(bound)) - strictSelect(Out(first), Out(second)) - strictSelect(In(first), In(second)) + strictSelect(InvB(first), InvB(bound)) + strictSelect(Inv(first), Inv(bound)) + strictSelect(Out(first), Out(second)) + strictSelect(In(first), In(second)) strictSelect(InB(first), InB(second)) - strictSelect(Out(Inv(first)), Out(Inv(second))) - strictSelect(In(Inv(first)), In(Inv(second))) + strictSelect(Out(Inv(first)), Out(Inv(second))) + strictSelect(In(Inv(first)), In(Inv(second))) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt index 30961f5da6f..662cb6bd402 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt @@ -9,5 +9,5 @@ class First : Common class Second : Common fun test(first: First, second: Second) { - select(first, second) + select(first, second) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt deleted file mode 100644 index e29973f346f..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -//!DIAGNOSTICS: -UNUSED_PARAMETER - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} - -open class A -class B: A() -class C: A() -class D - -fun test1(a: A, b: B, c: C) { - assertEquals1(a, b) - assertEquals1(b, c) - - assertEquals1(3, 3) - assertEquals1(1 or 2, 2 or 1) -} - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {} - -fun test() { - expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) } -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt index 09337b56616..efd1fe7d595 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL //!DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt deleted file mode 100644 index 52f24c84d08..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt +++ /dev/null @@ -1,79 +0,0 @@ -// !LANGUAGE: -ProhibitConcurrentHashMapContains -// FULL_JDK - -class A : java.util.concurrent.ConcurrentHashMap() { - operator fun contains(x: Char): Boolean = true -} -class B : java.util.concurrent.ConcurrentHashMap() { - override fun contains(value: Any?): Boolean { - return super.contains(value) - } -} - -class C : java.util.concurrent.ConcurrentHashMap() { - operator override fun contains(value: Any?): Boolean { - return super.contains(value) - } -} - -fun main() { - val hm = java.util.concurrent.ConcurrentHashMap() - "" in hm - "" !in hm - 1 !in hm - 2 in hm - - hm.contains("") - hm.contains(1) - - "" in (hm as Map) - "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) - - val a = A() - "" in a - "" !in a - 1 !in a - 2 in a - - ' ' in a - ' ' !in a - a.contains("") - a.contains(1) - - "" in (a as Map) - "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) - - val b = B() - "" in b - "" !in b - 1 !in b - 2 in b - - b.contains("") - b.contains(1) - - "" in (b as Map) - "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) - - // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird - val c = C() - "" in c - "" !in c - 1 !in c - 2 in c - - c.contains("") - c.contains(1) - - "" in (c as Map) - "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) -} - diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt index 1afd85ba221..7345681fa1c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: -ProhibitConcurrentHashMapContains // FULL_JDK diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt deleted file mode 100644 index 5308cee86ce..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt +++ /dev/null @@ -1,78 +0,0 @@ -// !LANGUAGE: +ProhibitConcurrentHashMapContains -// FULL_JDK - -class A : java.util.concurrent.ConcurrentHashMap() { - operator fun contains(x: Char): Boolean = true -} -class B : java.util.concurrent.ConcurrentHashMap() { - override fun contains(value: Any?): Boolean { - return super.contains(value) - } -} - -class C : java.util.concurrent.ConcurrentHashMap() { - operator override fun contains(value: Any?): Boolean { - return super.contains(value) - } -} - -fun main() { - val hm = java.util.concurrent.ConcurrentHashMap() - "" in hm - "" !in hm - 1 !in hm - 2 in hm - - hm.contains("") - hm.contains(1) - - "" in (hm as Map) - "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) - - val a = A() - "" in a - "" !in a - 1 !in a - 2 in a - - ' ' in a - ' ' !in a - a.contains("") - a.contains(1) - - "" in (a as Map) - "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) - - val b = B() - "" in b - "" !in b - 1 !in b - 2 in b - - b.contains("") - b.contains(1) - - "" in (b as Map) - "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) - - // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird - val c = C() - "" in c - "" !in c - 1 !in c - 2 in c - - c.contains("") - c.contains(1) - - "" in (c as Map) - "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt index 1eede5465ec..81e154b28db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ProhibitConcurrentHashMapContains // FULL_JDK diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt index 2aae13e99de..366e087d92b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt @@ -19,7 +19,7 @@ open class Case1 { x.get(0) x.size x.isEmpty() - x[null] + x[null] } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt index 2aae13e99de..366e087d92b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt @@ -19,7 +19,7 @@ open class Case1 { x.get(0) x.size x.isEmpty() - x[null] + x[null] } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt index 2aae13e99de..366e087d92b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt @@ -19,7 +19,7 @@ open class Case1 { x.get(0) x.size x.isEmpty() - x[null] + x[null] } } } diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/StandardClassIds.kt b/core/compiler.common/src/org/jetbrains/kotlin/name/StandardClassIds.kt index 638ee23b640..87f053a9ef6 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/StandardClassIds.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/StandardClassIds.kt @@ -163,6 +163,8 @@ object StandardClassIds { val FlexibleNullability = "FlexibleNullability".internalIrId() val EnhancedNullability = "EnhancedNullability".jvmInternalId() + val OnlyInputTypes = "OnlyInputTypes".internalId() + val RestrictsSuspension = "RestrictsSuspension".coroutinesId() val WasExperimental = "WasExperimental".baseId() diff --git a/libraries/tools/kotlin-tooling-core/src/test/kotlin/org/jetbrains/kotlin/tooling/core/TypeTest.kt b/libraries/tools/kotlin-tooling-core/src/test/kotlin/org/jetbrains/kotlin/tooling/core/TypeTest.kt index 33a63c8d9b2..3657c12de38 100644 --- a/libraries/tools/kotlin-tooling-core/src/test/kotlin/org/jetbrains/kotlin/tooling/core/TypeTest.kt +++ b/libraries/tools/kotlin-tooling-core/src/test/kotlin/org/jetbrains/kotlin/tooling/core/TypeTest.kt @@ -96,7 +96,7 @@ class TypeTest { ) } - @Suppress("RemoveExplicitTypeArguments", "TYPE_INFERENCE_ONLY_INPUT_TYPES_WARNING") + @Suppress("RemoveExplicitTypeArguments", "TYPE_INFERENCE_ONLY_INPUT_TYPES_WARNING", "TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR") @Test fun `test - equals`() { assertEquals(extrasTypeOf>(), extrasTypeOf>())