KT-2195 error "Only safe calls are allowed ..." but it is function param (val)
#KT-2195
This commit is contained in:
@@ -411,11 +411,21 @@ public class CallResolver {
|
||||
for (ResolutionCandidate<D> resolutionCandidate : task.getCandidates()) {
|
||||
TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create(task.trace);
|
||||
Collection<CallResolutionContext<D, F>> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace);
|
||||
Collection<ResolvedCallWithTrace<F>> calls = Lists.newArrayList();
|
||||
for (CallResolutionContext<D, F> context : contexts) {
|
||||
|
||||
performResolutionForCandidateCall(context, task);
|
||||
calls.addAll(callTransformer.transformCall(context, this, task));
|
||||
|
||||
/* important for 'variable as function case': temporary bind reference to descriptor (will be rewritten)
|
||||
to have a binding to variable while 'invoke' call resolve */
|
||||
task.tracing.bindReference(context.candidateCall.getTrace(), context.candidateCall);
|
||||
|
||||
Collection<ResolvedCallWithTrace<F>> calls = callTransformer.transformCall(context, this, task);
|
||||
|
||||
for (ResolvedCallWithTrace<F> call : calls) {
|
||||
task.tracing.bindReference(call.getTrace(), call);
|
||||
task.tracing.bindResolvedCall(call.getTrace(), call);
|
||||
task.getResolvedCalls().add(call);
|
||||
}
|
||||
|
||||
context.candidateCall.getTrace().addAllMyDataTo(traceForResolutionCache, new Predicate<WritableSlice>() {
|
||||
@Override
|
||||
@@ -425,11 +435,6 @@ public class CallResolver {
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
for (ResolvedCallWithTrace<F> call : calls) {
|
||||
|
||||
task.tracing.bindResolvedCall(call.getTrace(), call);
|
||||
task.getResolvedCalls().add(call);
|
||||
}
|
||||
}
|
||||
|
||||
Set<ResolvedCallWithTrace<F>> successfulCandidates = Sets.newLinkedHashSet();
|
||||
|
||||
@@ -98,12 +98,16 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
||||
|
||||
public final TracingStrategy tracing = new TracingStrategy() {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
descriptor = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall().getResultingDescriptor();
|
||||
}
|
||||
trace.record(REFERENCE_TARGET, reference, descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {
|
||||
trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ import java.util.List;
|
||||
/*package*/ interface TracingStrategy {
|
||||
TracingStrategy EMPTY = new TracingStrategy() {
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {}
|
||||
|
||||
@@ -83,6 +86,7 @@ import java.util.List;
|
||||
@Override
|
||||
public void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor descriptor) {}
|
||||
};
|
||||
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall);
|
||||
|
||||
<D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall);
|
||||
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public class AutoCastUtils {
|
||||
// else if (expression instanceof JetThisExpression) {
|
||||
// return castThis(dataFlowInfo, receiver);
|
||||
// }
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.INSTANCE.createDataFlowValue(receiver.getExpression(),receiver.getType(),
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.INSTANCE.createDataFlowValue(receiver.getExpression(), receiver.getType(),
|
||||
bindingContext);
|
||||
List<ReceiverDescriptor> result = Lists.newArrayList();
|
||||
for (JetType possibleType : dataFlowInfo.getPossibleTypes(dataFlowValue)) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//KT-2195 error "Only safe calls are allowed ..." but it is function param (val)
|
||||
package foo
|
||||
|
||||
private fun sendCommand<T>(errorCallback: (()->Unit)? = null) {
|
||||
if (errorCallback != null) {
|
||||
errorCallback()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user