diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index c96242bb331..b3816f7bbf6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -73,8 +73,6 @@ public class CallResolver { private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", ExpressionTypingVisitorDispatcher.typeInfoPerfCounter); - public static boolean useNewResolve = !"false".equals(System.getProperty("kotlin.internal.new_resolve")); - public CallResolver( @NotNull KotlinBuiltIns builtIns ) { @@ -152,7 +150,7 @@ public class CallResolver { } @NotNull - public OverloadResolutionResults resolveCallForInvoke( + private OverloadResolutionResults resolveCallForInvoke( @NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing ) { @@ -162,7 +160,7 @@ public class CallResolver { } @NotNull - private OverloadResolutionResults computeTasksAndResolveCall( + private OverloadResolutionResults computeTasksAndResolveCall( @NotNull BasicCallResolutionContext context, @NotNull Name name, @NotNull KtReferenceExpression referenceExpression, @@ -173,15 +171,15 @@ public class CallResolver { } @NotNull - private OverloadResolutionResults computeTasksAndResolveCall( + private OverloadResolutionResults computeTasksAndResolveCall( @NotNull final BasicCallResolutionContext context, @NotNull final Name name, @NotNull final TracingStrategy tracing, @NotNull final ResolveKind kind ) { - return callResolvePerfCounter.time(new Function0>() { + return callResolvePerfCounter.time(new Function0>() { @Override - public OverloadResolutionResults invoke() { + public OverloadResolutionResults invoke() { TaskContextForMigration contextForMigration = new TaskContextForMigration( kind, name, null ); @@ -191,7 +189,7 @@ public class CallResolver { } @NotNull - private OverloadResolutionResults computeTasksFromCandidatesAndResolvedCall( + private OverloadResolutionResults computeTasksFromCandidatesAndResolvedCall( @NotNull BasicCallResolutionContext context, @NotNull KtReferenceExpression referenceExpression, @NotNull Collection> candidates @@ -201,14 +199,14 @@ public class CallResolver { } @NotNull - private OverloadResolutionResults computeTasksFromCandidatesAndResolvedCall( + private OverloadResolutionResults computeTasksFromCandidatesAndResolvedCall( @NotNull final BasicCallResolutionContext context, @NotNull final Collection> candidates, @NotNull final TracingStrategy tracing ) { - return callResolvePerfCounter.time(new Function0>() { + return callResolvePerfCounter.time(new Function0>() { @Override - public OverloadResolutionResults invoke() { + public OverloadResolutionResults invoke() { TaskContextForMigration contextForMigration = new TaskContextForMigration( ResolveKind.GIVEN_CANDIDATES, null, candidates ); @@ -270,13 +268,13 @@ public class CallResolver { ResolveKind.FUNCTION); } else if (calleeExpression instanceof KtConstructorCalleeExpression) { - return resolveCallForConstructor(context, (KtConstructorCalleeExpression) calleeExpression); + return (OverloadResolutionResults) resolveCallForConstructor(context, (KtConstructorCalleeExpression) calleeExpression); } else if (calleeExpression instanceof KtConstructorDelegationReferenceExpression) { KtConstructorDelegationCall delegationCall = (KtConstructorDelegationCall) context.call.getCallElement(); DeclarationDescriptor container = context.scope.getOwnerDescriptor(); assert container instanceof ConstructorDescriptor : "Trying to resolve JetConstructorDelegationCall not in constructor. scope.ownerDescriptor = " + container; - return resolveConstructorDelegationCall(context, delegationCall, (KtConstructorDelegationReferenceExpression) calleeExpression, + return (OverloadResolutionResults) resolveConstructorDelegationCall(context, delegationCall, (KtConstructorDelegationReferenceExpression) calleeExpression, (ConstructorDescriptor) container); } else if (calleeExpression == null) { @@ -302,7 +300,7 @@ public class CallResolver { return resolveCallForInvoke(context.replaceCall(call), tracingForInvoke); } - private OverloadResolutionResults resolveCallForConstructor( + private OverloadResolutionResults resolveCallForConstructor( @NotNull BasicCallResolutionContext context, @NotNull KtConstructorCalleeExpression expression ) { @@ -335,17 +333,17 @@ public class CallResolver { return checkArgumentTypesAndFail(context); } - Pair>, BasicCallResolutionContext> candidatesAndContext = + Pair>, BasicCallResolutionContext> candidatesAndContext = prepareCandidatesAndContextForConstructorCall(constructedType, context); - Collection> candidates = candidatesAndContext.getFirst(); + Collection> candidates = candidatesAndContext.getFirst(); context = candidatesAndContext.getSecond(); return computeTasksFromCandidatesAndResolvedCall(context, functionReference, candidates); } @Nullable - public OverloadResolutionResults resolveConstructorDelegationCall( + public OverloadResolutionResults resolveConstructorDelegationCall( @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull DataFlowInfo dataFlowInfo, @NotNull ConstructorDescriptor constructorDescriptor, @NotNull KtConstructorDelegationCall call @@ -375,7 +373,7 @@ public class CallResolver { } @NotNull - private OverloadResolutionResults resolveConstructorDelegationCall( + private OverloadResolutionResults resolveConstructorDelegationCall( @NotNull BasicCallResolutionContext context, @NotNull KtConstructorDelegationCall call, @NotNull KtConstructorDelegationReferenceExpression calleeExpression, @@ -415,9 +413,9 @@ public class CallResolver { calleeConstructor.getContainingDeclaration().getDefaultType() : DescriptorUtils.getSuperClassType(currentClassDescriptor); - Pair>, BasicCallResolutionContext> candidatesAndContext = + Pair>, BasicCallResolutionContext> candidatesAndContext = prepareCandidatesAndContextForConstructorCall(superType, context); - Collection> candidates = candidatesAndContext.getFirst(); + Collection> candidates = candidatesAndContext.getFirst(); context = candidatesAndContext.getSecond(); TracingStrategy tracing = call.isImplicit() ? @@ -436,13 +434,13 @@ public class CallResolver { } @NotNull - private static Pair>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall( + private static Pair>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall( @NotNull KotlinType superType, @NotNull BasicCallResolutionContext context ) { if (!(superType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) { - return new Pair>, BasicCallResolutionContext>( - Collections.>emptyList(), context); + return new Pair>, BasicCallResolutionContext>( + Collections.>emptyList(), context); } ClassDescriptor superClass = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); @@ -457,10 +455,10 @@ public class CallResolver { context = context.replaceExpectedType(superType); } - Collection> candidates = + Collection> candidates = CallResolverUtilKt.createResolutionCandidatesForConstructors(context.scope, context.call, superClass, knownTypeParametersSubstitutor); - return new Pair>, BasicCallResolutionContext>(candidates, context); + return new Pair>, BasicCallResolutionContext>(candidates, context); } private static boolean anyConstructorHasDeclaredTypeParameters(@Nullable ClassifierDescriptor classDescriptor) { @@ -476,7 +474,7 @@ public class CallResolver { @NotNull final Call call, @NotNull final TracingStrategy tracing, @NotNull final ResolutionContext context, - @NotNull final ResolutionCandidate candidate, + @NotNull final ResolutionCandidate candidate, @Nullable final MutableDataFlowInfoForArguments dataFlowInfoForArguments ) { return callResolvePerfCounter.time(new Function0>() { @@ -485,10 +483,10 @@ public class CallResolver { BasicCallResolutionContext basicCallResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments); - Set> candidates = Collections.singleton(candidate); + Set> candidates = Collections.singleton(candidate); - TaskContextForMigration contextForMigration = - new TaskContextForMigration( + TaskContextForMigration contextForMigration = + new TaskContextForMigration( ResolveKind.GIVEN_CANDIDATES, null, candidates ); @@ -498,7 +496,7 @@ public class CallResolver { }); } - private OverloadResolutionResultsImpl doResolveCallOrGetCachedResults( + private OverloadResolutionResultsImpl doResolveCallOrGetCachedResults( @NotNull BasicCallResolutionContext context, @NotNull TaskContextForMigration contextForMigration, @NotNull TracingStrategy tracing @@ -512,7 +510,7 @@ public class CallResolver { BindingContextUtilsKt.recordScope(newContext.trace, newContext.scope, newContext.call.getCalleeExpression()); BindingContextUtilsKt.recordDataFlowInfo(newContext, newContext.call.getCalleeExpression()); - OverloadResolutionResultsImpl results = doResolveCall(newContext, contextForMigration, tracing); + OverloadResolutionResultsImpl results = doResolveCall(newContext, contextForMigration, tracing); DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace(); if (deltasTraceForTypeInference != null) { deltasTraceForTypeInference.addOwnDataTo(traceToResolveCall); @@ -570,7 +568,7 @@ public class CallResolver { } @NotNull - private OverloadResolutionResultsImpl doResolveCall( + private OverloadResolutionResultsImpl doResolveCall( @NotNull BasicCallResolutionContext context, @NotNull TaskContextForMigration contextForMigration, @NotNull TracingStrategy tracing @@ -595,11 +593,12 @@ public class CallResolver { if (contextForMigration.resolveKind != ResolveKind.GIVEN_CANDIDATES) { assert contextForMigration.name != null; - return (OverloadResolutionResultsImpl) + return (OverloadResolutionResultsImpl) newCallResolver.runResolve(context, contextForMigration.name, contextForMigration.resolveKind, tracing); } else { - return (OverloadResolutionResultsImpl) newCallResolver.runResolveForGivenCandidates(context, tracing, contextForMigration.givenCandidates); + assert contextForMigration.givenCandidates != null; + return newCallResolver.runResolveForGivenCandidates(context, tracing, contextForMigration.givenCandidates); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index ec1525f0e00..18be2c4ec8e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -172,7 +172,7 @@ fun createResolutionCandidatesForConstructors( call: Call, classWithConstructors: ClassDescriptor, knownSubstitutor: TypeSubstitutor? = null -): Collection> { +): Collection> { val constructors = classWithConstructors.constructors if (constructors.isEmpty()) return emptyList() @@ -196,5 +196,5 @@ fun createResolutionCandidatesForConstructors( dispatchReceiver = null } - return constructors.map { ResolutionCandidate.create(call, it, dispatchReceiver, null, receiverKind, knownSubstitutor) } + return constructors.map { ResolutionCandidate.create(call, it, dispatchReceiver, null, receiverKind, knownSubstitutor) } } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/VariableAsFunctionResolvedCall.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/VariableAsFunctionResolvedCall.kt index f8f82a9c6af..373017da2df 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/VariableAsFunctionResolvedCall.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/VariableAsFunctionResolvedCall.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ package org.jetbrains.kotlin.resolve.calls.model import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus import org.jetbrains.kotlin.resolve.DelegatingBindingTrace -import org.jetbrains.kotlin.resolve.calls.CallResolver +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus interface VariableAsFunctionResolvedCall { val functionCall: ResolvedCall @@ -47,11 +46,7 @@ class VariableAsFunctionResolvedCallImpl( override fun getStatus(): ResolutionStatus = variableCall.status.combine(functionCall.status) override fun getTrace(): DelegatingBindingTrace { - //functionCall.trace is temporary trace above variableCall.trace and is committed already - if (CallResolver.useNewResolve) { - return functionCall.trace - } - return variableCall.trace + return functionCall.trace } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 2bba4529916..4ac84c171ae 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,8 +105,8 @@ public class ControlStructureTypingUtils { construct, argumentNames, isArgumentNullable); TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context); TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType); - ResolutionCandidate resolutionCandidate = - ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor); + ResolutionCandidate resolutionCandidate = + ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor); OverloadResolutionResults results = callResolver.resolveCallWithKnownCandidate( call, tracing, context, resolutionCandidate, dataFlowInfoForArguments); assert results.isSingleResult() : "Not single result after resolving one known candidate";