[FE 1.0] Take care callable reference candidates with recursive candidate return type
^KT-51844 Fixed
This commit is contained in:
committed by
teamcity
parent
ec6ec20728
commit
9f31f074da
+6
@@ -13858,6 +13858,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
|
|||||||
+6
@@ -13858,6 +13858,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
|
|||||||
+6
@@ -13858,6 +13858,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
|
|||||||
+6
@@ -3129,6 +3129,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
+8
@@ -195,6 +195,14 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
SmartCastDiagnostic::class.java -> reportSmartCast(diagnostic as SmartCastDiagnostic)
|
SmartCastDiagnostic::class.java -> reportSmartCast(diagnostic as SmartCastDiagnostic)
|
||||||
UnstableSmartCastDiagnosticError::class.java,
|
UnstableSmartCastDiagnosticError::class.java,
|
||||||
UnstableSmartCastResolutionError::class.java -> reportUnstableSmartCast(diagnostic as UnstableSmartCast)
|
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 -> {
|
VisibilityErrorOnArgument::class.java -> {
|
||||||
diagnostic as VisibilityErrorOnArgument
|
diagnostic as VisibilityErrorOnArgument
|
||||||
val invisibleMember = diagnostic.invisibleMember
|
val invisibleMember = diagnostic.invisibleMember
|
||||||
|
|||||||
+1
-1
@@ -502,7 +502,7 @@ class NewResolutionOldInference(
|
|||||||
extensionReceiverCandidates: List<ReceiverValueWithSmartCastInfo>
|
extensionReceiverCandidates: List<ReceiverValueWithSmartCastInfo>
|
||||||
): MyCandidate = error("${this::class.simpleName} doesn't support candidates with multiple extension receiver candidates")
|
): 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")
|
throw IllegalStateException("Not supported creating error candidate for the old type inference candidate factory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -19,8 +19,9 @@ package org.jetbrains.kotlin.util;
|
|||||||
import com.intellij.openapi.application.Application;
|
import com.intellij.openapi.application.Application;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.types.error.LazyWrappedTypeComputationException;
|
||||||
|
|
||||||
public class ReenteringLazyValueComputationException extends RuntimeException {
|
public class ReenteringLazyValueComputationException extends LazyWrappedTypeComputationException {
|
||||||
public ReenteringLazyValueComputationException() {
|
public ReenteringLazyValueComputationException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
@@ -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.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
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.VisibilityError
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.VisibilityErrorOnArgument
|
import org.jetbrains.kotlin.resolve.calls.tower.VisibilityErrorOnArgument
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.isInapplicable
|
import org.jetbrains.kotlin.resolve.calls.tower.isInapplicable
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.TypeCheckerHasRanIntoRecursion
|
||||||
|
|
||||||
class CallableReferenceArgumentResolver(val callableReferenceOverloadConflictResolver: CallableReferenceOverloadConflictResolver) {
|
class CallableReferenceArgumentResolver(val callableReferenceOverloadConflictResolver: CallableReferenceOverloadConflictResolver) {
|
||||||
fun processCallableReferenceArgument(
|
fun processCallableReferenceArgument(
|
||||||
@@ -46,6 +48,7 @@ class CallableReferenceArgumentResolver(val callableReferenceOverloadConflictRes
|
|||||||
val transformedDiagnostic = when (it) {
|
val transformedDiagnostic = when (it) {
|
||||||
is CompatibilityWarning -> CompatibilityWarningOnArgument(argument, it.candidate)
|
is CompatibilityWarning -> CompatibilityWarningOnArgument(argument, it.candidate)
|
||||||
is VisibilityError -> VisibilityErrorOnArgument(argument, it.invisibleMember)
|
is VisibilityError -> VisibilityErrorOnArgument(argument, it.invisibleMember)
|
||||||
|
is RecursiveCallableReferenceType -> TypeCheckerHasRanIntoRecursion(argument)
|
||||||
else -> it
|
else -> it
|
||||||
}
|
}
|
||||||
diagnosticsHolder.addDiagnostic(transformedDiagnostic)
|
diagnosticsHolder.addDiagnostic(transformedDiagnostic)
|
||||||
|
|||||||
+1
-1
@@ -273,7 +273,7 @@ class KotlinCallCompleter(
|
|||||||
constraintSystem.errors.forEach(diagnosticsHolder::addError)
|
constraintSystem.errors.forEach(diagnosticsHolder::addError)
|
||||||
|
|
||||||
if (returnType is ErrorType && returnType.kind == ErrorTypeKind.RECURSIVE_TYPE) {
|
if (returnType is ErrorType && returnType.kind == ErrorTypeKind.RECURSIVE_TYPE) {
|
||||||
diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion)
|
diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+47
-8
@@ -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.inference.model.TypeVariableTypeConstructor
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
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.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||||
import org.jetbrains.kotlin.types.*
|
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.ErrorUtils
|
||||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
|
||||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
@@ -43,7 +43,7 @@ class CallableReferencesCandidateFactory(
|
|||||||
private val CallableReceiver.asReceiverValueForVisibilityChecks: ReceiverValue
|
private val CallableReceiver.asReceiverValueForVisibilityChecks: ReceiverValue
|
||||||
get() = receiver.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 errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString())
|
||||||
val errorDescriptor = errorScope.getContributedFunctions(kotlinCall.rhsName, scopeTower.location).first()
|
val errorDescriptor = errorScope.getContributedFunctions(kotlinCall.rhsName, scopeTower.location).first()
|
||||||
|
|
||||||
@@ -56,21 +56,36 @@ class CallableReferencesCandidateFactory(
|
|||||||
buildTypeWithConversions = kotlinCall is CallableReferenceKotlinCallArgument
|
buildTypeWithConversions = kotlinCall is CallableReferenceKotlinCallArgument
|
||||||
)
|
)
|
||||||
|
|
||||||
return CallableReferenceResolutionCandidate(
|
val candidate = CallableReferenceResolutionCandidate(
|
||||||
errorDescriptor, dispatchReceiver = null, extensionReceiver = null,
|
errorDescriptor, dispatchReceiver = null, extensionReceiver = null,
|
||||||
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, reflectionCandidateType, callableReferenceAdaptation,
|
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, reflectionCandidateType, callableReferenceAdaptation,
|
||||||
kotlinCall, expectedType, callComponents, scopeTower, resolutionCallbacks, baseSystem
|
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,
|
towerCandidate: CandidateWithBoundDispatchReceiver,
|
||||||
explicitReceiverKind: ExplicitReceiverKind,
|
explicitReceiverKind: ExplicitReceiverKind,
|
||||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): CallableReferenceResolutionCandidate {
|
): CallableReferenceResolutionCandidate {
|
||||||
val dispatchCallableReceiver =
|
val dispatchCallableReceiver = towerCandidate.dispatchReceiver?.let {
|
||||||
towerCandidate.dispatchReceiver?.let { toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER) }
|
toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER)
|
||||||
val extensionCallableReceiver = extensionReceiver?.let { toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.EXTENSION_RECEIVER) }
|
}
|
||||||
|
val extensionCallableReceiver = extensionReceiver?.let {
|
||||||
|
toCallableReceiver(it, explicitReceiverKind == ExplicitReceiverKind.EXTENSION_RECEIVER)
|
||||||
|
}
|
||||||
val candidateDescriptor = towerCandidate.descriptor
|
val candidateDescriptor = towerCandidate.descriptor
|
||||||
val diagnostics = SmartList<KotlinCallDiagnostic>()
|
val diagnostics = SmartList<KotlinCallDiagnostic>()
|
||||||
|
|
||||||
@@ -122,6 +137,30 @@ class CallableReferencesCandidateFactory(
|
|||||||
return createCallableReferenceCallCandidate(diagnostics)
|
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].
|
* The function is called only inside [NoExplicitReceiverScopeTowerProcessor] with [TowerData.BothTowerLevelAndContextReceiversGroup].
|
||||||
* This case involves only [SimpleCandidateFactory].
|
* This case involves only [SimpleCandidateFactory].
|
||||||
|
|||||||
+8
-2
@@ -116,8 +116,14 @@ class WrongCountOfTypeArguments(
|
|||||||
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
|
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
object TypeCheckerHasRanIntoRecursion : KotlinCallDiagnostic(INAPPLICABLE) {
|
class TypeCheckerHasRanIntoRecursion(val onArgument: KotlinCallArgument? = null) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
override fun report(reporter: DiagnosticReporter) {
|
||||||
|
return if (onArgument != null) {
|
||||||
|
reporter.onCallArgument(onArgument, this)
|
||||||
|
} else {
|
||||||
|
reporter.onCall(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callable reference resolution
|
// Callable reference resolution
|
||||||
|
|||||||
+2
-1
@@ -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.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
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.descriptorUtil.hasDynamicExtensionAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||||
@@ -163,7 +164,7 @@ class SimpleCandidateFactory(
|
|||||||
return candidate
|
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 errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString())
|
||||||
val errorDescriptor = if (kotlinCall.callKind == KotlinCallKind.VARIABLE) {
|
val errorDescriptor = if (kotlinCall.callKind == KotlinCallKind.VARIABLE) {
|
||||||
errorScope.getContributedVariables(kotlinCall.name, scopeTower.location)
|
errorScope.getContributedVariables(kotlinCall.name, scopeTower.location)
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ object ResolvedUsingNewFeatures : ResolutionDiagnostic(RESOLVED_NEED_PRESERVE_CO
|
|||||||
object UnstableSmartCastDiagnostic : ResolutionDiagnostic(UNSTABLE_SMARTCAST)
|
object UnstableSmartCastDiagnostic : ResolutionDiagnostic(UNSTABLE_SMARTCAST)
|
||||||
object HiddenExtensionRelatedToDynamicTypes : ResolutionDiagnostic(HIDDEN)
|
object HiddenExtensionRelatedToDynamicTypes : ResolutionDiagnostic(HIDDEN)
|
||||||
object HiddenDescriptor : ResolutionDiagnostic(HIDDEN)
|
object HiddenDescriptor : ResolutionDiagnostic(HIDDEN)
|
||||||
|
object RecursiveCallableReferenceType : ResolutionDiagnostic(INAPPLICABLE)
|
||||||
|
|
||||||
object InvokeConventionCallNoOperatorModifier : ResolutionDiagnostic(CONVENTION_ERROR)
|
object InvokeConventionCallNoOperatorModifier : ResolutionDiagnostic(CONVENTION_ERROR)
|
||||||
object InfixCallNoInfixModifier : ResolutionDiagnostic(CONVENTION_ERROR)
|
object InfixCallNoInfixModifier : ResolutionDiagnostic(CONVENTION_ERROR)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
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.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
||||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||||
@@ -47,7 +48,7 @@ interface CandidateFactory<out C : Candidate> {
|
|||||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): C
|
): C
|
||||||
|
|
||||||
fun createErrorCandidate(): C
|
fun createErrorCandidate(reason: ErrorCandidateReason = ErrorCandidateReason.OTHER): C
|
||||||
|
|
||||||
fun createCandidate(
|
fun createCandidate(
|
||||||
towerCandidate: CandidateWithBoundDispatchReceiver,
|
towerCandidate: CandidateWithBoundDispatchReceiver,
|
||||||
|
|||||||
+8
@@ -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 }
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND: JVM, JVM_IR, ANDROID, ANDROID_IR
|
|
||||||
// IGNORE_LIGHT_ANALYSIS
|
// IGNORE_LIGHT_ANALYSIS
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate<R, T>
|
|||||||
class GitLabChangesProcessor: DatabaseEntity {
|
class GitLabChangesProcessor: DatabaseEntity {
|
||||||
var buildProcessors by <!DEBUG_INFO_EXPRESSION_TYPE("Delegate<GitLabChangesProcessor, kotlin.collections.MutableCollection<GitLabBuildProcessor>>"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many(
|
var buildProcessors by <!DEBUG_INFO_EXPRESSION_TYPE("Delegate<GitLabChangesProcessor, kotlin.collections.MutableCollection<GitLabBuildProcessor>>"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many(
|
||||||
GitLabBuildProcessor::class.java,
|
GitLabBuildProcessor::class.java,
|
||||||
GitLabBuildProcessor::processor
|
<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR, TYPE_MISMATCH!>GitLabBuildProcessor::<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>processor<!><!>
|
||||||
)<!>
|
)<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate<R, T>
|
|||||||
class GitLabChangesProcessor: DatabaseEntity {
|
class GitLabChangesProcessor: DatabaseEntity {
|
||||||
var buildProcessors by <!DEBUG_INFO_EXPRESSION_TYPE("Delegate<GitLabChangesProcessor, kotlin.collections.MutableCollection<GitLabBuildProcessor>>"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many(
|
var buildProcessors by <!DEBUG_INFO_EXPRESSION_TYPE("Delegate<GitLabChangesProcessor, kotlin.collections.MutableCollection<GitLabBuildProcessor>>"), TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>child_many(
|
||||||
GitLabBuildProcessor::class.java,
|
GitLabBuildProcessor::class.java,
|
||||||
GitLabBuildProcessor::processor
|
<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR, TYPE_MISMATCH!>GitLabBuildProcessor::<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>processor<!><!>
|
||||||
)<!>
|
)<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -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(<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR, TYPE_MISMATCH!>this::<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>contains<!><!>)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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<T> {
|
|
||||||
public SortedListModel(Comparator<? super T> comparator) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
val model = SortedListModel<Schematic>(Comparator.comparing { b1: Schematic ->
|
|
||||||
when {
|
|
||||||
b1.error != null -> 2
|
|
||||||
b1.name!!.contains(":") -> 1
|
|
||||||
else -> 0
|
|
||||||
}
|
|
||||||
}.thenComparing { b1: Schematic -> b1.name!! })
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ class ProcessorWithParent : Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ProcessorWithChildren : Entity {
|
class ProcessorWithChildren : Entity {
|
||||||
var processors by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>children(ProcessorWithParent::class.java, ProcessorWithParent::processor)<!>
|
var processors by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>children(ProcessorWithParent::class.java, <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR, TYPE_MISMATCH!>ProcessorWithParent::<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>processor<!><!>)<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
class Processor2WithParent : Entity {
|
class Processor2WithParent : Entity {
|
||||||
|
|||||||
Generated
+6
@@ -13864,6 +13864,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
|
|||||||
+6
@@ -3033,6 +3033,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
+6
@@ -3129,6 +3129,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
+10
-5
@@ -2658,6 +2658,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
@@ -13951,11 +13956,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Fir extends AbstractLightAnalysisModeTest {
|
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")
|
@TestMetadata("SuspendExtension.kt")
|
||||||
public void ignoreSuspendExtension() throws Exception {
|
public void ignoreSuspendExtension() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt");
|
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");
|
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")
|
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
||||||
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/incorrectBytecodeWithEnhancedNullability.kt");
|
runTest("compiler/testData/codegen/box/fir/incorrectBytecodeWithEnhancedNullability.kt");
|
||||||
|
|||||||
+8
@@ -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()
|
||||||
+6
@@ -1983,6 +1983,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
+6
@@ -2025,6 +2025,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
+5
@@ -1808,6 +1808,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
+6
@@ -2077,6 +2077,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/kt50172.kt");
|
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
|
@Test
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user