Revert "[FE 1.0] Resolve this and super calls through the new type inference infra"
This reverts commit bab8047bb3.
This commit is contained in:
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||||
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||||
@@ -291,7 +290,7 @@ class DelegatedPropertyResolver(
|
|||||||
|
|
||||||
resolutionErrorFactory?.let {
|
resolutionErrorFactory?.let {
|
||||||
val expectedFunction = renderCall(delegateOperatorCall, trace.bindingContext)
|
val expectedFunction = renderCall(delegateOperatorCall, trace.bindingContext)
|
||||||
trace.reportDiagnosticOnce(it.on(delegateExpression, expectedFunction, delegateOperatorResults.resultingCalls))
|
trace.report(it.on(delegateExpression, expectedFunction, delegateOperatorResults.resultingCalls))
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolutionErrorFactory != null
|
return resolutionErrorFactory != null
|
||||||
|
|||||||
@@ -290,21 +290,6 @@ public class CallResolver {
|
|||||||
callResolutionContext, resolutionCandidates, TracingStrategyImpl.create(expression, call));
|
callResolutionContext, resolutionCandidates, TracingStrategyImpl.create(expression, call));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public OverloadResolutionResults<ReceiverParameterDescriptor> resolveThisOrSuperCallWithGivenDescriptor(
|
|
||||||
@NotNull ExpressionTypingContext context,
|
|
||||||
@NotNull Call call,
|
|
||||||
@NotNull ReceiverParameterDescriptor descriptor
|
|
||||||
) {
|
|
||||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
|
|
||||||
|
|
||||||
return PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
|
||||||
callResolutionContext,
|
|
||||||
Collections.singletonList(descriptor),
|
|
||||||
TracingStrategy.EMPTY
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(
|
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@@ -620,7 +605,7 @@ public class CallResolver {
|
|||||||
if (newInferenceEnabled && resolutionKind instanceof NewResolutionOldInference.ResolutionKind.GivenCandidates) {
|
if (newInferenceEnabled && resolutionKind instanceof NewResolutionOldInference.ResolutionKind.GivenCandidates) {
|
||||||
assert resolutionTask.givenCandidates != null;
|
assert resolutionTask.givenCandidates != null;
|
||||||
BindingContextUtilsKt.recordScope(context.trace, context.scope, context.call.getCalleeExpression());
|
BindingContextUtilsKt.recordScope(context.trace, context.scope, context.call.getCalleeExpression());
|
||||||
return PSICallResolver.runResolutionAndInferenceForGivenOldCandidates(context, resolutionTask.givenCandidates, tracing);
|
return PSICallResolver.runResolutionAndInferenceForGivenCandidates(context, resolutionTask.givenCandidates, tracing);
|
||||||
}
|
}
|
||||||
|
|
||||||
TemporaryBindingTrace traceToResolveCall = TemporaryBindingTrace.create(context.trace, "trace to resolve call", call);
|
TemporaryBindingTrace traceToResolveCall = TemporaryBindingTrace.create(context.trace, "trace to resolve call", call);
|
||||||
|
|||||||
@@ -144,36 +144,8 @@ class PSICallResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenDescriptors(
|
|
||||||
context: BasicCallResolutionContext,
|
|
||||||
descriptors: Collection<CallableDescriptor>,
|
|
||||||
tracingStrategy: TracingStrategy
|
|
||||||
): OverloadResolutionResults<D> {
|
|
||||||
val isSpecialFunction = descriptors.any { it.name in SPECIAL_FUNCTION_NAMES }
|
|
||||||
val kotlinCall = toKotlinCall(
|
|
||||||
context, KotlinCallKind.FUNCTION, context.call, givenCandidatesName, tracingStrategy, isSpecialFunction, null
|
|
||||||
)
|
|
||||||
val scopeTower = ASTScopeTower(context)
|
|
||||||
val resolutionCallbacks = createResolutionCallbacks(context)
|
|
||||||
val givenCandidates = descriptors.map {
|
|
||||||
GivenCandidate(
|
|
||||||
it,
|
|
||||||
dispatchReceiver = null,
|
|
||||||
knownTypeParametersResultingSubstitutor = null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val result = kotlinCallResolver.resolveAndCompleteGivenCandidates(
|
|
||||||
scopeTower, resolutionCallbacks, kotlinCall, calculateExpectedType(context), givenCandidates, context.collectAllCandidates
|
|
||||||
)
|
|
||||||
|
|
||||||
return convertToOverloadResolutionResults<D>(context, result, tracingStrategy).also {
|
|
||||||
clearCacheForApproximationResults()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// actually, `D` is at least FunctionDescriptor, but right now because of CallResolver it isn't possible change upper bound for `D`
|
// actually, `D` is at least FunctionDescriptor, but right now because of CallResolver it isn't possible change upper bound for `D`
|
||||||
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenOldCandidates(
|
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenCandidates(
|
||||||
context: BasicCallResolutionContext,
|
context: BasicCallResolutionContext,
|
||||||
resolutionCandidates: Collection<OldResolutionCandidate<D>>,
|
resolutionCandidates: Collection<OldResolutionCandidate<D>>,
|
||||||
tracingStrategy: TracingStrategy
|
tracingStrategy: TracingStrategy
|
||||||
|
|||||||
+18
-3
@@ -58,6 +58,7 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability;
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate;
|
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.NewAbstractResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.tower.NewAbstractResolvedCall;
|
||||||
@@ -635,13 +636,27 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
) {
|
) {
|
||||||
BindingTrace trace = context.trace;
|
BindingTrace trace = context.trace;
|
||||||
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
|
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
|
||||||
OverloadResolutionResults<ReceiverParameterDescriptor> results =
|
OldResolutionCandidate<ReceiverParameterDescriptor> resolutionCandidate =
|
||||||
components.callResolver.resolveThisOrSuperCallWithGivenDescriptor(context, call, descriptor);
|
OldResolutionCandidate.create(
|
||||||
|
call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
|
||||||
|
|
||||||
ResolvedCall<?> resolvedCall = results.getResultingCall();
|
ResolvedCallImpl<ReceiverParameterDescriptor> resolvedCall =
|
||||||
|
ResolvedCallImpl.create(resolutionCandidate,
|
||||||
|
TemporaryBindingTrace.create(trace, "Fake trace for fake 'this' or 'super' resolved call"),
|
||||||
|
TracingStrategy.EMPTY,
|
||||||
|
new DataFlowInfoForArgumentsImpl(context.dataFlowInfo, call));
|
||||||
|
resolvedCall.markCallAsCompleted();
|
||||||
|
|
||||||
trace.record(RESOLVED_CALL, call, resolvedCall);
|
trace.record(RESOLVED_CALL, call, resolvedCall);
|
||||||
trace.record(CALL, expression, call);
|
trace.record(CALL, expression, call);
|
||||||
|
|
||||||
|
if (context.trace.wantsDiagnostics()) {
|
||||||
|
CallCheckerContext callCheckerContext =
|
||||||
|
createCallCheckerContext(context);
|
||||||
|
for (CallChecker checker : components.callCheckers) {
|
||||||
|
checker.check(resolvedCall, expression, callCheckerContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDeclaredInClass(ReceiverParameterDescriptor receiver) {
|
private static boolean isDeclaredInClass(ReceiverParameterDescriptor receiver) {
|
||||||
|
|||||||
+1
-2
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.calls.model
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.builtins.ReflectionTypes
|
import org.jetbrains.kotlin.builtins.ReflectionTypes
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||||
@@ -49,7 +48,7 @@ class KotlinCallComponents(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class GivenCandidate(
|
class GivenCandidate(
|
||||||
val descriptor: CallableDescriptor,
|
val descriptor: FunctionDescriptor,
|
||||||
val dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
val dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
val knownTypeParametersResultingSubstitutor: TypeSubstitutor?
|
val knownTypeParametersResultingSubstitutor: TypeSubstitutor?
|
||||||
)
|
)
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
class A {
|
||||||
|
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>MyProperty1()<!>
|
||||||
|
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>getMyProperty1()<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
||||||
|
|
||||||
|
class MyProperty1<T, R> {
|
||||||
|
|
||||||
|
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
|
||||||
|
throw Exception()
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun setValue(i: Int, j: Any, k: Int) {
|
||||||
|
println("set")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------
|
||||||
|
|
||||||
|
class B {
|
||||||
|
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>MyProperty2()<!>
|
||||||
|
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>getMyProperty2()<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <A, B> getMyProperty2() = MyProperty2<A, B>()
|
||||||
|
|
||||||
|
class MyProperty2<T, R> {
|
||||||
|
|
||||||
|
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
|
||||||
|
throw Exception()
|
||||||
|
}
|
||||||
|
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun setValue(i: Int) {
|
||||||
|
println("set")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------
|
||||||
|
fun println(a: Any?) = a
|
||||||
Vendored
+4
-5
@@ -1,11 +1,10 @@
|
|||||||
// FIR_IDENTICAL
|
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>MyProperty1()<!>
|
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>MyProperty1<!>()<!>
|
||||||
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>getMyProperty1()<!>
|
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty1<!>()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
||||||
@@ -24,8 +23,8 @@ class MyProperty1<T, R> {
|
|||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
class B {
|
class B {
|
||||||
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>MyProperty2()<!>
|
var a5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>MyProperty2<!>()<!>
|
||||||
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>getMyProperty2()<!>
|
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty2<!>()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <A, B> getMyProperty2() = MyProperty2<A, B>()
|
fun <A, B> getMyProperty2() = MyProperty2<A, B>()
|
||||||
|
|||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
class A {
|
|
||||||
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
|
||||||
}
|
|
||||||
|
|
||||||
var aTopLevel: Int by Delegate()
|
|
||||||
|
|
||||||
class Delegate {
|
|
||||||
operator fun getValue(t: Nothing?, p: KProperty<*>): Int {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
operator fun setValue(t: Nothing?, p: KProperty<*>, a: Int) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
var aTopLevel: Int by Delegate()
|
var aTopLevel: Int by Delegate()
|
||||||
|
|||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
class A {
|
|
||||||
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
|
||||||
}
|
|
||||||
|
|
||||||
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
|
||||||
|
|
||||||
class Delegate {
|
|
||||||
fun getValue(t: Nothing, p: KProperty<*>): Int {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
fun setValue(t: Nothing, p: KProperty<*>, a: Int) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
|
|||||||
Reference in New Issue
Block a user