[NI] Propagate class to extend inference through resolution context
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
@@ -32,6 +21,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.OperatorCallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemCompleter
|
||||
@@ -575,7 +565,7 @@ class DelegatedPropertyResolver(
|
||||
val contextForProvideDelegate = ExpressionTypingContext.newContext(
|
||||
traceToResolveConventionMethods, scopeForDelegate, delegateTypeInfo.dataFlowInfo,
|
||||
NO_EXPECTED_TYPE, ContextDependency.DEPENDENT, StatementFilter.NONE,
|
||||
languageVersionSettings, dataFlowValueFactory
|
||||
languageVersionSettings, dataFlowValueFactory, InferenceSession.default
|
||||
)
|
||||
|
||||
val delegateTypeConstructor = delegateTypeInfo.type?.constructor
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls;
|
||||
@@ -35,6 +24,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallKind;
|
||||
@@ -307,7 +297,7 @@ public class CallResolver {
|
||||
return resolveFunctionCall(
|
||||
BasicCallResolutionContext.create(
|
||||
trace, scope, call, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
isAnnotationContext, languageVersionSettings, dataFlowValueFactory
|
||||
isAnnotationContext, languageVersionSettings, dataFlowValueFactory, InferenceSession.Companion.getDefault()
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -435,7 +425,8 @@ public class CallResolver {
|
||||
dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
false,
|
||||
languageVersionSettings,
|
||||
dataFlowValueFactory);
|
||||
dataFlowValueFactory,
|
||||
InferenceSession.Companion.getDefault());
|
||||
|
||||
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
|
||||
|
||||
|
||||
+34
-20
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.context;
|
||||
@@ -24,6 +13,7 @@ import org.jetbrains.kotlin.psi.Call;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
@@ -48,11 +38,33 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BasicCallResolutionContext create(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
boolean isAnnotationContext,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
||||
new ResolutionResultsCacheImpl(), null,
|
||||
StatementFilter.NONE, isAnnotationContext, false, false,
|
||||
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings,
|
||||
dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -72,7 +84,7 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
new ResolutionResultsCacheImpl(), null,
|
||||
StatementFilter.NONE, isAnnotationContext, false, false,
|
||||
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings,
|
||||
dataFlowValueFactory);
|
||||
dataFlowValueFactory, InferenceSession.Companion.getDefault());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -84,7 +96,8 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
|
||||
context.resolutionResultsCache, dataFlowInfoForArguments,
|
||||
context.statementFilter, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory);
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory,
|
||||
context.inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -107,12 +120,13 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return new BasicCallResolutionContext(
|
||||
trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -120,6 +134,6 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
return new BasicCallResolutionContext(
|
||||
trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-19
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.context;
|
||||
@@ -25,6 +14,7 @@ import org.jetbrains.kotlin.psi.Call;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
@@ -61,11 +51,13 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
this.candidateCall = candidateCall;
|
||||
this.tracing = tracing;
|
||||
this.candidateResolveMode = candidateResolveMode;
|
||||
@@ -82,7 +74,8 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
context.resolutionResultsCache, context.dataFlowInfoForArguments,
|
||||
context.statementFilter,
|
||||
candidateResolveMode, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory);
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory,
|
||||
context.inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -94,7 +87,8 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
|
||||
context.dataFlowInfoForArguments, context.statementFilter,
|
||||
CandidateResolveMode.FULLY, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory);
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings, context.dataFlowValueFactory,
|
||||
context.inferenceSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,12 +104,13 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return new CallCandidateResolutionContext<>(
|
||||
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
||||
resolutionResultsCache, dataFlowInfoForArguments, statementFilter,
|
||||
candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider,
|
||||
languageVersionSettings, dataFlowValueFactory);
|
||||
languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.context;
|
||||
@@ -24,6 +13,7 @@ import org.jetbrains.kotlin.psi.Call;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
@@ -57,11 +47,12 @@ public abstract class CallResolutionContext<Context extends CallResolutionContex
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
||||
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings,
|
||||
dataFlowValueFactory);
|
||||
dataFlowValueFactory, inferenceSession);
|
||||
this.call = call;
|
||||
this.checkArguments = checkArguments;
|
||||
if (dataFlowInfoForArguments != null) {
|
||||
|
||||
+31
-25
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.context;
|
||||
@@ -25,6 +14,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
@@ -68,6 +58,9 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull
|
||||
public final DataFlowValueFactory dataFlowValueFactory;
|
||||
|
||||
@NotNull
|
||||
public final InferenceSession inferenceSession;
|
||||
|
||||
/**
|
||||
* Used for analyzing expression in the given context.
|
||||
* Should be used for going through parents to find containing function, loop etc.
|
||||
@@ -94,7 +87,8 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory factory
|
||||
@NotNull DataFlowValueFactory factory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
this.trace = trace;
|
||||
this.scope = scope;
|
||||
@@ -110,6 +104,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
this.expressionContextProvider = expressionContextProvider;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
this.dataFlowValueFactory = factory;
|
||||
this.inferenceSession = inferenceSession;
|
||||
}
|
||||
|
||||
protected abstract Context create(
|
||||
@@ -124,7 +119,8 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
);
|
||||
|
||||
@NotNull
|
||||
@@ -137,14 +133,16 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
public Context replaceBindingTrace(@NotNull BindingTrace trace) {
|
||||
if (this.trace == trace) return self();
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceDataFlowInfo(@NotNull DataFlowInfo newDataFlowInfo) {
|
||||
if (newDataFlowInfo == dataFlowInfo) return self();
|
||||
return create(trace, scope, newDataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -152,28 +150,32 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
if (newExpectedType == null) return replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
|
||||
if (expectedType == newExpectedType) return self();
|
||||
return create(trace, scope, dataFlowInfo, newExpectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceScope(@NotNull LexicalScope newScope) {
|
||||
if (newScope == scope) return self();
|
||||
return create(trace, newScope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceContextDependency(@NotNull ContextDependency newContextDependency) {
|
||||
if (newContextDependency == contextDependency) return self();
|
||||
return create(trace, scope, dataFlowInfo, expectedType, newContextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceResolutionResultsCache(@NotNull ResolutionResultsCache newResolutionResultsCache) {
|
||||
if (newResolutionResultsCache == resolutionResultsCache) return self();
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, newResolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -184,25 +186,29 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull
|
||||
public Context replaceCollectAllCandidates(boolean newCollectAllCandidates) {
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
newCollectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
newCollectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceStatementFilter(@NotNull StatementFilter statementFilter) {
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceCallPosition(@NotNull CallPosition callPosition) {
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceExpressionContextProvider(@NotNull Function1<KtExpression, KtExpression> expressionContextProvider) {
|
||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory);
|
||||
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+4
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
@@ -193,6 +182,8 @@ class KotlinResolutionCallbacksImpl(
|
||||
return constantExpressionEvaluator.evaluateExpression(expression, temporaryBindingTrace, expectedType) != null
|
||||
}
|
||||
|
||||
override val inferenceSession = topLevelCallContext.inferenceSession
|
||||
|
||||
private fun findCommonParent(callElement: KtExpression, receiver: ReceiverKotlinCallArgument?): KtExpression {
|
||||
if (receiver == null) return callElement
|
||||
return PsiTreeUtil.findCommonParent(callElement, receiver.psiExpression)?.safeAs() ?: callElement
|
||||
|
||||
+2
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.types.expressions;
|
||||
|
||||
+50
-24
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.types.expressions;
|
||||
@@ -22,6 +11,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
@@ -39,7 +29,22 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
) {
|
||||
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE, languageVersionSettings, dataFlowValueFactory);
|
||||
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE,
|
||||
languageVersionSettings, dataFlowValueFactory, InferenceSession.Companion.getDefault());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingContext newContext(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE,
|
||||
languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -51,10 +56,27 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory) {
|
||||
return newContext(trace, scope, dataFlowInfo, expectedType, contextDependency,
|
||||
new ResolutionResultsCacheImpl(), statementFilter, false, languageVersionSettings, dataFlowValueFactory,
|
||||
InferenceSession.Companion.getDefault());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingContext newContext(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return newContext(trace, scope, dataFlowInfo, expectedType, contextDependency,
|
||||
new ResolutionResultsCacheImpl(), statementFilter, false, languageVersionSettings, dataFlowValueFactory);
|
||||
new ResolutionResultsCacheImpl(), statementFilter, false, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -65,7 +87,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
context.statementFilter,
|
||||
context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||
context.callPosition, context.expressionContextProvider, context.languageVersionSettings,
|
||||
context.dataFlowValueFactory);
|
||||
context.dataFlowValueFactory, context.inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -77,7 +99,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
context.isAnnotationContext, isDebuggerContext, context.collectAllCandidates,
|
||||
context.callPosition, context.expressionContextProvider,
|
||||
context.languageVersionSettings,
|
||||
context.dataFlowValueFactory);
|
||||
context.dataFlowValueFactory, context.inferenceSession);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -91,12 +113,14 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
@NotNull StatementFilter statementFilter,
|
||||
boolean isAnnotationContext,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return new ExpressionTypingContext(
|
||||
trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache,
|
||||
statementFilter, isAnnotationContext, false, false,
|
||||
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings, dataFlowValueFactory);
|
||||
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings, dataFlowValueFactory,
|
||||
inferenceSession);
|
||||
}
|
||||
|
||||
private ExpressionTypingContext(
|
||||
@@ -113,11 +137,12 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
||||
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider,
|
||||
languageVersionSettings, dataFlowValueFactory);
|
||||
languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,12 +158,13 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory
|
||||
@NotNull DataFlowValueFactory dataFlowValueFactory,
|
||||
@NotNull InferenceSession inferenceSession
|
||||
) {
|
||||
return new ExpressionTypingContext(trace, scope, dataFlowInfo,
|
||||
expectedType, contextDependency, resolutionResultsCache,
|
||||
statementFilter, isAnnotationContext, isDebuggerContext,
|
||||
collectAllCandidates, callPosition, expressionContextProvider,
|
||||
languageVersionSettings, dataFlowValueFactory);
|
||||
languageVersionSettings, dataFlowValueFactory, inferenceSession);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
@@ -50,4 +39,6 @@ interface KotlinResolutionCallbacks {
|
||||
fun createReceiverWithSmartCastInfo(resolvedAtom: ResolvedCallAtom): ReceiverValueWithSmartCastInfo?
|
||||
|
||||
fun isCompileTimeConstant(resolvedAtom: ResolvedCallAtom, expectedType: UnwrappedType): Boolean
|
||||
|
||||
val inferenceSession: InferenceSession
|
||||
}
|
||||
+6
@@ -163,4 +163,10 @@ class KotlinCallCompleter(
|
||||
systemStorage
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
interface InferenceSession {
|
||||
companion object {
|
||||
val default = object : InferenceSession {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user