Revert "[FE 1.0] Resolve special construct calls through the new type inference infra"
This reverts commit e66cc9a639.
This commit is contained in:
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.config.LanguageFeature;
|
|||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0;
|
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||||
@@ -46,7 +45,6 @@ import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
||||||
@@ -293,23 +291,17 @@ public class CallResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public <D extends CallableDescriptor> OverloadResolutionResults<D> resolveCallWithGivenDescriptor(
|
public OverloadResolutionResults<ReceiverParameterDescriptor> resolveThisOrSuperCallWithGivenDescriptor(
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull Call call,
|
@NotNull Call call,
|
||||||
@NotNull D descriptor,
|
@NotNull ReceiverParameterDescriptor descriptor
|
||||||
@NotNull TracingStrategy tracingStrategy,
|
|
||||||
@Nullable TypeSubstitutor substitutor,
|
|
||||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
|
||||||
) {
|
) {
|
||||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(
|
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
|
||||||
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments
|
|
||||||
);
|
|
||||||
|
|
||||||
return PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
return PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||||
callResolutionContext,
|
callResolutionContext,
|
||||||
Collections.singletonList(descriptor),
|
Collections.singletonList(descriptor),
|
||||||
tracingStrategy,
|
TracingStrategy.EMPTY
|
||||||
substitutor
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,6 +580,27 @@ public class CallResolver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithKnownCandidate(
|
||||||
|
@NotNull Call call,
|
||||||
|
@NotNull TracingStrategy tracing,
|
||||||
|
@NotNull ResolutionContext<?> context,
|
||||||
|
@NotNull OldResolutionCandidate<FunctionDescriptor> candidate,
|
||||||
|
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||||
|
) {
|
||||||
|
return callResolvePerfCounter.<OverloadResolutionResults<FunctionDescriptor>>time(() -> {
|
||||||
|
BasicCallResolutionContext basicCallResolutionContext =
|
||||||
|
BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments);
|
||||||
|
|
||||||
|
Set<OldResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
|
||||||
|
|
||||||
|
ResolutionTask<FunctionDescriptor> resolutionTask = new ResolutionTask<>(
|
||||||
|
new NewResolutionOldInference.ResolutionKind.GivenCandidates(), null, candidates
|
||||||
|
);
|
||||||
|
|
||||||
|
return doResolveCallOrGetCachedResults(basicCallResolutionContext, resolutionTask, tracing);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> doResolveCallOrGetCachedResults(
|
private <D extends CallableDescriptor> OverloadResolutionResults<D> doResolveCallOrGetCachedResults(
|
||||||
@NotNull BasicCallResolutionContext context,
|
@NotNull BasicCallResolutionContext context,
|
||||||
@NotNull ResolutionTask<D> resolutionTask,
|
@NotNull ResolutionTask<D> resolutionTask,
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ class PSICallResolver(
|
|||||||
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenDescriptors(
|
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenDescriptors(
|
||||||
context: BasicCallResolutionContext,
|
context: BasicCallResolutionContext,
|
||||||
descriptors: Collection<CallableDescriptor>,
|
descriptors: Collection<CallableDescriptor>,
|
||||||
tracingStrategy: TracingStrategy,
|
tracingStrategy: TracingStrategy
|
||||||
substitutor: TypeSubstitutor? = null
|
|
||||||
): OverloadResolutionResults<D> {
|
): OverloadResolutionResults<D> {
|
||||||
val isSpecialFunction = descriptors.any { it.name in SPECIAL_FUNCTION_NAMES }
|
val isSpecialFunction = descriptors.any { it.name in SPECIAL_FUNCTION_NAMES }
|
||||||
val kotlinCall = toKotlinCall(
|
val kotlinCall = toKotlinCall(
|
||||||
@@ -160,7 +159,7 @@ class PSICallResolver(
|
|||||||
GivenCandidate(
|
GivenCandidate(
|
||||||
it,
|
it,
|
||||||
dispatchReceiver = null,
|
dispatchReceiver = null,
|
||||||
knownTypeParametersResultingSubstitutor = substitutor
|
knownTypeParametersResultingSubstitutor = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ fun KtElement.getCall(context: BindingContext): Call? {
|
|||||||
else -> element.getCalleeExpressionIfAny()
|
else -> element.getCalleeExpressionIfAny()
|
||||||
}
|
}
|
||||||
if (reference != null) {
|
if (reference != null) {
|
||||||
return context[CALL, reference] ?: context[CALL, element]
|
return context[CALL, reference]
|
||||||
}
|
}
|
||||||
return context[CALL, element]
|
return context[CALL, element]
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -636,7 +636,7 @@ 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 =
|
OverloadResolutionResults<ReceiverParameterDescriptor> results =
|
||||||
components.callResolver.resolveCallWithGivenDescriptor(context, call, descriptor, TracingStrategy.EMPTY, null, null);
|
components.callResolver.resolveThisOrSuperCallWithGivenDescriptor(context, call, descriptor);
|
||||||
|
|
||||||
ResolvedCall<?> resolvedCall = results.getResultingCall();
|
ResolvedCall<?> resolvedCall = results.getResultingCall();
|
||||||
|
|
||||||
|
|||||||
+6
-10
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||||
|
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.util.CallMaker;
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.AnnotationsForResolveUtilsKt;
|
import org.jetbrains.kotlin.resolve.descriptorUtil.AnnotationsForResolveUtilsKt;
|
||||||
@@ -161,17 +162,12 @@ public class ControlStructureTypingUtils {
|
|||||||
) {
|
) {
|
||||||
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
|
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
|
||||||
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
|
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
|
||||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenDescriptor(
|
OldResolutionCandidate<FunctionDescriptor> resolutionCandidate =
|
||||||
context, call, function, tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments
|
OldResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
|
||||||
);
|
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
|
||||||
|
call, tracing, context, resolutionCandidate, dataFlowInfoForArguments);
|
||||||
assert results.isSingleResult() : "Not single result after resolving one known candidate";
|
assert results.isSingleResult() : "Not single result after resolving one known candidate";
|
||||||
|
return results.getResultingCall();
|
||||||
ResolvedCall<FunctionDescriptor> resolvedCall = results.getResultingCall();
|
|
||||||
|
|
||||||
context.trace.record(RESOLVED_CALL, call, resolvedCall);
|
|
||||||
context.trace.record(CALL, call.getCallElement(), call);
|
|
||||||
|
|
||||||
return resolvedCall;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
|
private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
|
||||||
|
|||||||
Vendored
+2
-2
@@ -9,8 +9,8 @@ class A(outer: Outer) {
|
|||||||
var g: String by outer.getContainer().getMyProperty()
|
var g: String by outer.getContainer().getMyProperty()
|
||||||
|
|
||||||
|
|
||||||
var b: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>foo(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())<!>
|
var b: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>foo(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())<!>
|
||||||
var r: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>foo(outer.getContainer().<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())<!>
|
var r: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>foo(outer.getContainer().<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())<!>
|
||||||
var e: String by <!DEBUG_INFO_MISSING_UNRESOLVED!>+<!> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())
|
var e: String by <!DEBUG_INFO_MISSING_UNRESOLVED!>+<!> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>())
|
||||||
var f: String by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>()) <!DEBUG_INFO_MISSING_UNRESOLVED!>-<!> 1
|
var f: String by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>()) <!DEBUG_INFO_MISSING_UNRESOLVED!>-<!> 1
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -7,7 +7,7 @@ class A<R>() {
|
|||||||
operator fun <T> setValue(t: Any?, p: KProperty<*>, x: T) = Unit
|
operator fun <T> setValue(t: Any?, p: KProperty<*>, x: T) = Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
var a1: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>A<!>()<!>
|
var a1: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>A<!>()<!>
|
||||||
var a2: Int by A<String>()
|
var a2: Int by A<String>()
|
||||||
|
|
||||||
class B<R>() {
|
class B<R>() {
|
||||||
@@ -24,4 +24,4 @@ class C<R>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var c1: Int by C()
|
var c1: Int by C()
|
||||||
var c2: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>C<Number>()<!>
|
var c2: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>C<Number>()<!>
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
var a: Int by A()
|
var a: Int by A()
|
||||||
var a1 by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
|
var a1 by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
|
||||||
|
|
||||||
var b: Int by B()
|
var b: Int by B()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class A {
|
|||||||
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
|
|
||||||
class Delegate {
|
class Delegate {
|
||||||
fun getValue(t: Nothing, p: KProperty<*>): Int {
|
fun getValue(t: Nothing, p: KProperty<*>): Int {
|
||||||
|
|||||||
Vendored
-23
@@ -1,23 +0,0 @@
|
|||||||
// FILE: J.java
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.*;
|
|
||||||
|
|
||||||
public class J {
|
|
||||||
|
|
||||||
public interface DP {
|
|
||||||
String getValue(Object a, Object b);
|
|
||||||
String setValue(Object a, Object b, Object c);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static DP staticNN;
|
|
||||||
@Nullable
|
|
||||||
public static DP staticN;
|
|
||||||
public static DP staticJ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: k.kt
|
|
||||||
|
|
||||||
var A by J.staticNN
|
|
||||||
var B by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>J.staticN<!>
|
|
||||||
var C by J.staticJ
|
|
||||||
Vendored
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FILE: J.java
|
// FILE: J.java
|
||||||
|
|
||||||
import org.jetbrains.annotations.*;
|
import org.jetbrains.annotations.*;
|
||||||
@@ -19,5 +20,5 @@ public class J {
|
|||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
var A by J.staticNN
|
var A by J.staticNN
|
||||||
var B by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>J.staticN<!>
|
var B by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>J.staticN<!>
|
||||||
var C by J.staticJ
|
var C by J.staticJ
|
||||||
|
|||||||
Reference in New Issue
Block a user