Fixed bug with property and function name clash.
Complete type inference dependent on function literals and expected type for variable as function calls not for 'invoke' calls
This commit is contained in:
@@ -340,14 +340,14 @@ public class CallResolver {
|
||||
@NotNull OverloadResolutionResultsImpl<D> results,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return;
|
||||
if (!results.isSingleResult()) {
|
||||
if (results.getResultCode() == INCOMPLETE_TYPE_INFERENCE) {
|
||||
argumentTypeResolver.checkTypesWithNoCallee(context, RESOLVE_FUNCTION_ARGUMENTS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//call for 'invoke' was completed earlier
|
||||
if (results.getResultingCall() instanceof VariableAsFunctionResolvedCall) return;
|
||||
|
||||
CallCandidateResolutionContext<D> candidateContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
|
||||
results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing);
|
||||
candidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext);
|
||||
@@ -358,6 +358,8 @@ public class CallResolver {
|
||||
@NotNull OverloadResolutionResultsImpl<D> results,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return results;
|
||||
|
||||
if (results.isSingleResult()) {
|
||||
Set<ValueArgument> unmappedArguments = results.getResultingCall().getCallToCompleteTypeArgumentInference().getUnmappedArguments();
|
||||
argumentTypeResolver.checkUnmappedArgumentTypes(context, unmappedArguments);
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallCandidateResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
@@ -195,7 +196,8 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
|
||||
|
||||
DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
|
||||
BasicCallResolutionContext basicCallResolutionContext = BasicCallResolutionContext.create(
|
||||
context.replaceBindingTrace(variableCallTrace), functionCall, context.checkArguments, context.dataFlowInfoForArguments);
|
||||
context.replaceBindingTrace(variableCallTrace).replaceContextDependency(ContextDependency.DEPENDENT),
|
||||
functionCall, context.checkArguments, context.dataFlowInfoForArguments);
|
||||
|
||||
// 'invoke' call resolve
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicCallResolutionContext, task.reference, Name.identifier("invoke"));
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package d
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): String {
|
||||
ListTag().test(listOf("a", "b"))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun ListTag.test(list: List<String>) {
|
||||
for (item in list) {
|
||||
item() {
|
||||
a {
|
||||
text = item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class HtmlTag
|
||||
open class ListTag : HtmlTag() {}
|
||||
class LI : ListTag() {}
|
||||
|
||||
public fun ListTag.item(body: LI.() -> Unit): Unit {}
|
||||
fun HtmlTag.a(contents: A.() -> Unit) {}
|
||||
|
||||
trait A : HtmlTag {
|
||||
public var text: String
|
||||
}
|
||||
|
||||
fun listOf(vararg strings: String): List<String> {
|
||||
val list = ArrayList<String>()
|
||||
for (s in strings) {
|
||||
list.add(s)
|
||||
}
|
||||
return list
|
||||
}
|
||||
@@ -1343,6 +1343,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/closures/closureInsideClosure/localFunInsideLocalFunDifferentSignatures.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAndFunctionNameClash.kt")
|
||||
public void testPropertyAndFunctionNameClash() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/closures/closureInsideClosure/propertyAndFunctionNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("threeLevels.kt")
|
||||
public void testThreeLevels() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/closures/closureInsideClosure/threeLevels.kt");
|
||||
|
||||
Reference in New Issue
Block a user