diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 71b78789284..3cfdbc0e86e 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -13858,6 +13858,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt51844.kt"); + } + @Test @TestMetadata("kt6175.kt") public void testKt6175() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 6b71812da3b..62607b5920f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -13858,6 +13858,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt51844.kt"); + } + @Test @TestMetadata("kt6175.kt") public void testKt6175() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 28a46cea25d..cb0f707759a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -13858,6 +13858,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt51844.kt"); + } + @Test @TestMetadata("kt6175.kt") public void testKt6175() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 6fa8bc4466e..c7d6c1677a0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -3129,6 +3129,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 9583fb36bed..219ee1b736a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -195,6 +195,14 @@ class DiagnosticReporterByTrackingStrategy( SmartCastDiagnostic::class.java -> reportSmartCast(diagnostic as SmartCastDiagnostic) UnstableSmartCastDiagnosticError::class.java, UnstableSmartCastResolutionError::class.java -> reportUnstableSmartCast(diagnostic as UnstableSmartCast) + TypeCheckerHasRanIntoRecursion::class.java -> { + diagnostic as TypeCheckerHasRanIntoRecursion + val argumentExpression = + diagnostic.onArgument?.psiCallArgument?.valueArgument?.getArgumentExpression() + if (argumentExpression != null) { + trace.report(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM.errorFactory.on(argumentExpression)) + } + } VisibilityErrorOnArgument::class.java -> { diagnostic as VisibilityErrorOnArgument val invisibleMember = diagnostic.invisibleMember diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index 70c3c272766..0a9ae26a170 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -502,7 +502,7 @@ class NewResolutionOldInference( extensionReceiverCandidates: List ): MyCandidate = error("${this::class.simpleName} doesn't support candidates with multiple extension receiver candidates") - override fun createErrorCandidate(): MyCandidate { + override fun createErrorCandidate(reason: ErrorCandidateReason): MyCandidate { throw IllegalStateException("Not supported creating error candidate for the old type inference candidate factory") } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/ReenteringLazyValueComputationException.java b/compiler/frontend/src/org/jetbrains/kotlin/util/ReenteringLazyValueComputationException.java index 5be947c2021..ed607710a45 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/ReenteringLazyValueComputationException.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/ReenteringLazyValueComputationException.java @@ -19,8 +19,9 @@ package org.jetbrains.kotlin.util; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.types.error.LazyWrappedTypeComputationException; -public class ReenteringLazyValueComputationException extends RuntimeException { +public class ReenteringLazyValueComputationException extends LazyWrappedTypeComputationException { public ReenteringLazyValueComputationException() { } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceArgumentResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceArgumentResolver.kt index 891a7e912cd..e0ce2e4fd2c 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceArgumentResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceArgumentResolver.kt @@ -8,9 +8,11 @@ package org.jetbrains.kotlin.resolve.calls.components import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.calls.tower.RecursiveCallableReferenceType import org.jetbrains.kotlin.resolve.calls.tower.VisibilityError import org.jetbrains.kotlin.resolve.calls.tower.VisibilityErrorOnArgument import org.jetbrains.kotlin.resolve.calls.tower.isInapplicable +import org.jetbrains.kotlin.resolve.calls.model.TypeCheckerHasRanIntoRecursion class CallableReferenceArgumentResolver(val callableReferenceOverloadConflictResolver: CallableReferenceOverloadConflictResolver) { fun processCallableReferenceArgument( @@ -46,6 +48,7 @@ class CallableReferenceArgumentResolver(val callableReferenceOverloadConflictRes val transformedDiagnostic = when (it) { is CompatibilityWarning -> CompatibilityWarningOnArgument(argument, it.candidate) is VisibilityError -> VisibilityErrorOnArgument(argument, it.invisibleMember) + is RecursiveCallableReferenceType -> TypeCheckerHasRanIntoRecursion(argument) else -> it } diagnosticsHolder.addDiagnostic(transformedDiagnostic) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt index 139e7d82a74..2e1175ea291 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt @@ -273,7 +273,7 @@ class KotlinCallCompleter( constraintSystem.errors.forEach(diagnosticsHolder::addError) if (returnType is ErrorType && returnType.kind == ErrorTypeKind.RECURSIVE_TYPE) { - diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion) + diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion()) } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/CallableReferencesCandidateFactory.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/CallableReferencesCandidateFactory.kt index ba69a1ef2b7..733a2e5343e 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/CallableReferencesCandidateFactory.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/CallableReferencesCandidateFactory.kt @@ -18,15 +18,15 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.calls.tower.* +import org.jetbrains.kotlin.resolve.calls.util.ErrorCandidateReason import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo import org.jetbrains.kotlin.types.* -import org.jetbrains.kotlin.types.error.ErrorScopeKind +import org.jetbrains.kotlin.types.error.* import org.jetbrains.kotlin.types.error.ErrorUtils -import org.jetbrains.kotlin.types.error.ErrorTypeKind import org.jetbrains.kotlin.types.expressions.CoercionStrategy import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.SmartList @@ -43,7 +43,7 @@ class CallableReferencesCandidateFactory( private val CallableReceiver.asReceiverValueForVisibilityChecks: ReceiverValue get() = receiver.receiverValue - override fun createErrorCandidate(): CallableReferenceResolutionCandidate { + override fun createErrorCandidate(reason: ErrorCandidateReason): CallableReferenceResolutionCandidate { val errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString()) val errorDescriptor = errorScope.getContributedFunctions(kotlinCall.rhsName, scopeTower.location).first() @@ -56,21 +56,36 @@ class CallableReferencesCandidateFactory( buildTypeWithConversions = kotlinCall is CallableReferenceKotlinCallArgument ) - return CallableReferenceResolutionCandidate( + val candidate = CallableReferenceResolutionCandidate( errorDescriptor, dispatchReceiver = null, extensionReceiver = null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, reflectionCandidateType, callableReferenceAdaptation, kotlinCall, expectedType, callComponents, scopeTower, resolutionCallbacks, baseSystem ) + + when (reason) { + ErrorCandidateReason.TYPE_COMPUTATION_RECURSION -> candidate.addDiagnostic(RecursiveCallableReferenceType) + ErrorCandidateReason.OTHER -> {} + } + + return candidate } - override fun createCandidate( + private fun KotlinType.isErrorRecursiveType(): Boolean { + val unwrapped = if (this is WrappedType && isComputed()) unwrap() else this + return unwrapped is ErrorType && unwrapped.kind == ErrorTypeKind.RECURSIVE_TYPE + } + + private fun createCandidateInternal( towerCandidate: CandidateWithBoundDispatchReceiver, explicitReceiverKind: ExplicitReceiverKind, extensionReceiver: ReceiverValueWithSmartCastInfo? ): CallableReferenceResolutionCandidate { - val dispatchCallableReceiver = - towerCandidate.dispatchReceiver?.let { toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER) } - val extensionCallableReceiver = extensionReceiver?.let { toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.EXTENSION_RECEIVER) } + val dispatchCallableReceiver = towerCandidate.dispatchReceiver?.let { + toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER) + } + val extensionCallableReceiver = extensionReceiver?.let { + toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.EXTENSION_RECEIVER) + } val candidateDescriptor = towerCandidate.descriptor val diagnostics = SmartList() @@ -122,6 +137,30 @@ class CallableReferencesCandidateFactory( return createCallableReferenceCallCandidate(diagnostics) } + override fun createCandidate( + towerCandidate: CandidateWithBoundDispatchReceiver, + explicitReceiverKind: ExplicitReceiverKind, + extensionReceiver: ReceiverValueWithSmartCastInfo? + ): CallableReferenceResolutionCandidate = + createRecursionTolerantCandidate(towerCandidate, explicitReceiverKind, extensionReceiver) { + createErrorCandidate(ErrorCandidateReason.TYPE_COMPUTATION_RECURSION) + } + + private fun createRecursionTolerantCandidate( + towerCandidate: CandidateWithBoundDispatchReceiver, + explicitReceiverKind: ExplicitReceiverKind, + extensionReceiver: ReceiverValueWithSmartCastInfo?, + onRecursion: () -> CallableReferenceResolutionCandidate, + ): CallableReferenceResolutionCandidate = + try { + val resolutionCandidate = createCandidateInternal(towerCandidate, explicitReceiverKind, extensionReceiver) + val returnType = resolutionCandidate.candidate.returnType + + if (returnType == null || !returnType.isErrorRecursiveType()) resolutionCandidate else onRecursion() + } catch (e: LazyWrappedTypeComputationException) { + onRecursion() + } + /** * The function is called only inside [NoExplicitReceiverScopeTowerProcessor] with [TowerData.BothTowerLevelAndContextReceiversGroup]. * This case involves only [SimpleCandidateFactory]. diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt index 38f93dfaa47..5ae0e11488a 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt @@ -116,8 +116,14 @@ class WrongCountOfTypeArguments( override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this) } -object TypeCheckerHasRanIntoRecursion : KotlinCallDiagnostic(INAPPLICABLE) { - override fun report(reporter: DiagnosticReporter) = reporter.onCall(this) +class TypeCheckerHasRanIntoRecursion(val onArgument: KotlinCallArgument? = null) : KotlinCallDiagnostic(INAPPLICABLE) { + override fun report(reporter: DiagnosticReporter) { + return if (onArgument != null) { + reporter.onCallArgument(onArgument, this) + } else { + reporter.onCall(this) + } + } } // Callable reference resolution diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/SimpleCandidateFactory.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/SimpleCandidateFactory.kt index aa18c5858cf..1d962252f42 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/SimpleCandidateFactory.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/SimpleCandidateFactory.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.calls.tower.* +import org.jetbrains.kotlin.resolve.calls.util.ErrorCandidateReason import org.jetbrains.kotlin.resolve.descriptorUtil.hasDynamicExtensionAnnotation import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo import org.jetbrains.kotlin.types.error.ErrorUtils @@ -163,7 +164,7 @@ class SimpleCandidateFactory( return candidate } - override fun createErrorCandidate(): SimpleResolutionCandidate { + override fun createErrorCandidate(reason: ErrorCandidateReason): SimpleResolutionCandidate { val errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString()) val errorDescriptor = if (kotlinCall.callKind == KotlinCallKind.VARIABLE) { errorScope.getContributedVariables(kotlinCall.name, scopeTower.location) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt index a7cc029bff1..e02818b97f6 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt @@ -154,6 +154,7 @@ object ResolvedUsingNewFeatures : ResolutionDiagnostic(RESOLVED_NEED_PRESERVE_CO object UnstableSmartCastDiagnostic : ResolutionDiagnostic(UNSTABLE_SMARTCAST) object HiddenExtensionRelatedToDynamicTypes : ResolutionDiagnostic(HIDDEN) object HiddenDescriptor : ResolutionDiagnostic(HIDDEN) +object RecursiveCallableReferenceType : ResolutionDiagnostic(INAPPLICABLE) object InvokeConventionCallNoOperatorModifier : ResolutionDiagnostic(CONVENTION_ERROR) object InfixCallNoInfixModifier : ResolutionDiagnostic(CONVENTION_ERROR) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt index 17922c544d8..581f5406577 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tower import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind +import org.jetbrains.kotlin.resolve.calls.util.ErrorCandidateReason import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope import org.jetbrains.kotlin.resolve.scopes.ImportingScope @@ -47,7 +48,7 @@ interface CandidateFactory { extensionReceiver: ReceiverValueWithSmartCastInfo? ): C - fun createErrorCandidate(): C + fun createErrorCandidate(reason: ErrorCandidateReason = ErrorCandidateReason.OTHER): C fun createCandidate( towerCandidate: CandidateWithBoundDispatchReceiver, diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/ErrorCandidateReason.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/ErrorCandidateReason.kt new file mode 100644 index 00000000000..315bd247c2e --- /dev/null +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/ErrorCandidateReason.kt @@ -0,0 +1,8 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.calls.util + +enum class ErrorCandidateReason { TYPE_COMPUTATION_RECURSION, OTHER } diff --git a/compiler/testData/codegen/box/callableReference/kt51844.kt b/compiler/testData/codegen/box/callableReference/kt51844.kt new file mode 100644 index 00000000000..83712bb4021 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/kt51844.kt @@ -0,0 +1,15 @@ +// WITH_STDLIB + +abstract class Foo { + abstract fun contains(x: Int); +} + +// ERROR: Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly +fun Foo.contains(vararg xs: Int) = xs.forEach(this::contains) + +fun box(): String { + object : Foo() { + override fun contains(x: Int) {} + }.contains(1) + return "OK" +} diff --git a/compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt b/compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt index d9665547fc7..c3445240282 100644 --- a/compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt +++ b/compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND: JVM, JVM_IR, ANDROID, ANDROID_IR // IGNORE_LIGHT_ANALYSIS // WITH_STDLIB // JVM_TARGET: 1.8 diff --git a/compiler/testData/diagnostics/tests/delegation/kt49477.kt b/compiler/testData/diagnostics/tests/delegation/kt49477.kt index 2efb3cc60fd..41d2fd3d087 100644 --- a/compiler/testData/diagnostics/tests/delegation/kt49477.kt +++ b/compiler/testData/diagnostics/tests/delegation/kt49477.kt @@ -26,7 +26,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate class GitLabChangesProcessor: DatabaseEntity { var buildProcessors by >"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many( GitLabBuildProcessor::class.java, - GitLabBuildProcessor::processor + GitLabBuildProcessor::processor ) } diff --git a/compiler/testData/diagnostics/tests/delegation/kt49477Error.kt b/compiler/testData/diagnostics/tests/delegation/kt49477Error.kt index e51ea6d7b9e..f6aad7b240a 100644 --- a/compiler/testData/diagnostics/tests/delegation/kt49477Error.kt +++ b/compiler/testData/diagnostics/tests/delegation/kt49477Error.kt @@ -27,7 +27,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate class GitLabChangesProcessor: DatabaseEntity { var buildProcessors by >"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many( GitLabBuildProcessor::class.java, - GitLabBuildProcessor::processor + GitLabBuildProcessor::processor ) } diff --git a/compiler/testData/diagnostics/tests/inference/kt51844.fir.kt b/compiler/testData/diagnostics/tests/inference/kt51844.fir.kt new file mode 100644 index 00000000000..6400879dcc2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt51844.fir.kt @@ -0,0 +1,11 @@ +// WITH_STDLIB + +abstract class Foo { +} + +// ERROR: Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly +fun Foo.contains(vararg xs: Int) = xs.forEach(this::contains) + +fun box(): String { + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/inference/kt51844.kt b/compiler/testData/diagnostics/tests/inference/kt51844.kt new file mode 100644 index 00000000000..f9fd990faff --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt51844.kt @@ -0,0 +1,11 @@ +// WITH_STDLIB + +abstract class Foo { +} + +// ERROR: Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly +fun Foo.contains(vararg xs: Int) = xs.forEach(this::contains) + +fun box(): String { + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/inference/kt51844.txt b/compiler/testData/diagnostics/tests/inference/kt51844.txt new file mode 100644 index 00000000000..4a40034cb7a --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt51844.txt @@ -0,0 +1,11 @@ +package + +public fun box(): kotlin.String +public fun Foo.contains(/*0*/ vararg xs: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit + +public abstract class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/kt50877.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/kt50877.fir.kt deleted file mode 100644 index 99d5b007510..00000000000 --- a/compiler/testData/diagnostics/tests/platformTypes/kt50877.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// FULL_JDK -// WITH_STDLIB - -// FILE: Schematic.kt -class Schematic { - var name: String? = null - - var error: String? = null - - override fun toString(): String { - return name!! - } -} - -// FILE: SortedListModel.java -import java.util.Comparator; - -public class SortedListModel { - public SortedListModel(Comparator comparator) { - } -} - - -// FILE: main.kt -val model = SortedListModel(Comparator.comparing { b1: Schematic -> - when { - b1.error != null -> 2 - b1.name!!.contains(":") -> 1 - else -> 0 - } -}.thenComparing { b1: Schematic -> b1.name!! }) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/kt50877.kt b/compiler/testData/diagnostics/tests/platformTypes/kt50877.kt index 99d5b007510..1b57f849afd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/kt50877.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/kt50877.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FULL_JDK // WITH_STDLIB diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.kt index 15832df530a..4de0fc2db1d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.kt @@ -8,7 +8,7 @@ class ProcessorWithParent : Entity { } class ProcessorWithChildren : Entity { - var processors by children(ProcessorWithParent::class.java, ProcessorWithParent::processor) + var processors by children(ProcessorWithParent::class.java, ProcessorWithParent::processor) } class Processor2WithParent : Entity { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 554ccb86c0f..f1f0d950188 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -13864,6 +13864,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt51844.kt"); + } + @Test @TestMetadata("kt6175.kt") public void testKt6175() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index d341fb20b66..e28868e8c37 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -3033,6 +3033,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 5663201d05b..5cb4fc67d50 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -3129,6 +3129,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index c938a160e9e..459ab5be8ae 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2658,6 +2658,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); @@ -13951,11 +13956,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Fir extends AbstractLightAnalysisModeTest { - @TestMetadata("flexibleIntegerLiterals.kt") - public void ignoreFlexibleIntegerLiterals() throws Exception { - runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt"); - } - @TestMetadata("SuspendExtension.kt") public void ignoreSuspendExtension() throws Exception { runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt"); @@ -14009,6 +14009,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt"); } + @TestMetadata("flexibleIntegerLiterals.kt") + public void testFlexibleIntegerLiterals() throws Exception { + runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt"); + } + @TestMetadata("incorrectBytecodeWithEnhancedNullability.kt") public void testIncorrectBytecodeWithEnhancedNullability() throws Exception { runTest("compiler/testData/codegen/box/fir/incorrectBytecodeWithEnhancedNullability.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/LazyWrappedTypeComputationException.kt b/core/descriptors/src/org/jetbrains/kotlin/types/error/LazyWrappedTypeComputationException.kt new file mode 100644 index 00000000000..44d0ee1f6da --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/LazyWrappedTypeComputationException.kt @@ -0,0 +1,8 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.types.error + +abstract class LazyWrappedTypeComputationException : RuntimeException() diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 113f722316d..14a7d78bd4b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -1983,6 +1983,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index ebc9d1b298f..1a8225fb53d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -2025,6 +2025,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ef796a4694c..80f7493bfee 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -1808,6 +1808,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 03af64f22aa..527d9deb807 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -2077,6 +2077,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/callableReference/kt50172.kt"); } + @Test + @TestMetadata("kt51844.kt") + public void testKt51844() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt51844.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception {