Propagate languageVersionSettings to resolution context
This commit is contained in:
@@ -304,7 +304,7 @@ class DelegatedPropertyResolver(
|
|||||||
else
|
else
|
||||||
TypeUtils.NO_EXPECTED_TYPE
|
TypeUtils.NO_EXPECTED_TYPE
|
||||||
|
|
||||||
val context = ExpressionTypingContext.newContext(trace, delegateFunctionsScope, dataFlowInfo, expectedType)
|
val context = ExpressionTypingContext.newContext(trace, delegateFunctionsScope, dataFlowInfo, expectedType, languageVersionSettings)
|
||||||
|
|
||||||
val hasThis = propertyDescriptor.extensionReceiverParameter != null || propertyDescriptor.dispatchReceiverParameter != null
|
val hasThis = propertyDescriptor.extensionReceiverParameter != null || propertyDescriptor.dispatchReceiverParameter != null
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ class DelegatedPropertyResolver(
|
|||||||
initializerScope: LexicalScope,
|
initializerScope: LexicalScope,
|
||||||
dataFlowInfo: DataFlowInfo
|
dataFlowInfo: DataFlowInfo
|
||||||
): OverloadResolutionResults<FunctionDescriptor> {
|
): OverloadResolutionResults<FunctionDescriptor> {
|
||||||
val context = ExpressionTypingContext.newContext(trace, initializerScope, dataFlowInfo, NO_EXPECTED_TYPE)
|
val context = ExpressionTypingContext.newContext(trace, initializerScope, dataFlowInfo, NO_EXPECTED_TYPE, languageVersionSettings)
|
||||||
return getProvideDelegateMethod(propertyDescriptor, delegateExpression, delegateExpressionType, context)
|
return getProvideDelegateMethod(propertyDescriptor, delegateExpression, delegateExpressionType, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +537,8 @@ class DelegatedPropertyResolver(
|
|||||||
traceToResolveConventionMethods, false, delegateExpression, ContextDependency.DEPENDENT)
|
traceToResolveConventionMethods, false, delegateExpression, ContextDependency.DEPENDENT)
|
||||||
|
|
||||||
val contextForProvideDelegate = ExpressionTypingContext.newContext(traceToResolveConventionMethods, scopeForDelegate, delegateType.dataFlowInfo,
|
val contextForProvideDelegate = ExpressionTypingContext.newContext(traceToResolveConventionMethods, scopeForDelegate, delegateType.dataFlowInfo,
|
||||||
NO_EXPECTED_TYPE, ContextDependency.DEPENDENT, StatementFilter.NONE)
|
NO_EXPECTED_TYPE, ContextDependency.DEPENDENT, StatementFilter.NONE,
|
||||||
|
languageVersionSettings)
|
||||||
|
|
||||||
val provideDelegateResults = getProvideDelegateMethod(
|
val provideDelegateResults = getProvideDelegateMethod(
|
||||||
variableDescriptor, delegateExpression, delegateType.type ?: return null, contextForProvideDelegate
|
variableDescriptor, delegateExpression, delegateType.type ?: return null, contextForProvideDelegate
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ public class DescriptorResolver {
|
|||||||
scope,
|
scope,
|
||||||
destructuringDeclaration, new TransientReceiver(type), /* initializer = */ null,
|
destructuringDeclaration, new TransientReceiver(type), /* initializer = */ null,
|
||||||
ExpressionTypingContext.newContext(
|
ExpressionTypingContext.newContext(
|
||||||
trace, scopeForDestructuring, DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE
|
trace, scopeForDestructuring, DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE, languageVersionSettings
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -782,7 +782,7 @@ public class DescriptorResolver {
|
|||||||
KtExpression initializer = destructuringDeclaration.getInitializer();
|
KtExpression initializer = destructuringDeclaration.getInitializer();
|
||||||
|
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
trace, scopeForDeclarationResolution, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE
|
trace, scopeForDeclarationResolution, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, languageVersionSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
ExpressionReceiver receiver = createReceiverForDestructuringDeclaration(destructuringDeclaration, context);
|
ExpressionReceiver receiver = createReceiverForDestructuringDeclaration(destructuringDeclaration, context);
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public class CallResolver {
|
|||||||
return resolveFunctionCall(
|
return resolveFunctionCall(
|
||||||
BasicCallResolutionContext.create(
|
BasicCallResolutionContext.create(
|
||||||
trace, scope, call, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
trace, scope, call, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
isAnnotationContext
|
isAnnotationContext, languageVersionSettings
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -429,7 +429,8 @@ public class CallResolver {
|
|||||||
CallMaker.makeCall(null, null, call),
|
CallMaker.makeCall(null, null, call),
|
||||||
NO_EXPECTED_TYPE,
|
NO_EXPECTED_TYPE,
|
||||||
dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
false);
|
false,
|
||||||
|
languageVersionSettings);
|
||||||
|
|
||||||
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
|
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.context;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.psi.Call;
|
import org.jetbrains.kotlin.psi.Call;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
@@ -44,11 +45,12 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
|||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||||
callPosition, expressionContextProvider);
|
callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -60,12 +62,13 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
|||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull ContextDependency contextDependency,
|
@NotNull ContextDependency contextDependency,
|
||||||
@NotNull CheckArgumentTypesMode checkArguments,
|
@NotNull CheckArgumentTypesMode checkArguments,
|
||||||
boolean isAnnotationContext
|
boolean isAnnotationContext,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
||||||
new ResolutionResultsCacheImpl(), null,
|
new ResolutionResultsCacheImpl(), null,
|
||||||
StatementFilter.NONE, isAnnotationContext, false, false,
|
StatementFilter.NONE, isAnnotationContext, false, false,
|
||||||
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER);
|
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -77,7 +80,7 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
|||||||
context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
|
context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
|
||||||
context.resolutionResultsCache, dataFlowInfoForArguments,
|
context.resolutionResultsCache, dataFlowInfoForArguments,
|
||||||
context.statementFilter, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
context.statementFilter, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||||
context.callPosition, context.expressionContextProvider);
|
context.callPosition, context.expressionContextProvider, context.languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -98,12 +101,13 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
|||||||
@NotNull StatementFilter statementFilter,
|
@NotNull StatementFilter statementFilter,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return new BasicCallResolutionContext(
|
return new BasicCallResolutionContext(
|
||||||
trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||||
callPosition, expressionContextProvider);
|
callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -111,6 +115,6 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
|||||||
return new BasicCallResolutionContext(
|
return new BasicCallResolutionContext(
|
||||||
trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates,
|
||||||
callPosition, expressionContextProvider);
|
callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-7
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.context;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.kotlin.psi.Call;
|
import org.jetbrains.kotlin.psi.Call;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
@@ -57,11 +58,12 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
|||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
|
||||||
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext,
|
dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
this.candidateCall = candidateCall;
|
this.candidateCall = candidateCall;
|
||||||
this.tracing = tracing;
|
this.tracing = tracing;
|
||||||
this.candidateResolveMode = candidateResolveMode;
|
this.candidateResolveMode = candidateResolveMode;
|
||||||
@@ -78,7 +80,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
|||||||
context.resolutionResultsCache, context.dataFlowInfoForArguments,
|
context.resolutionResultsCache, context.dataFlowInfoForArguments,
|
||||||
context.statementFilter,
|
context.statementFilter,
|
||||||
candidateResolveMode, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
candidateResolveMode, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||||
context.callPosition, context.expressionContextProvider);
|
context.callPosition, context.expressionContextProvider, context.languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -90,7 +92,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
|||||||
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
|
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
|
||||||
context.dataFlowInfoForArguments, context.statementFilter,
|
context.dataFlowInfoForArguments, context.statementFilter,
|
||||||
CandidateResolveMode.FULLY, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
CandidateResolveMode.FULLY, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||||
context.callPosition, context.expressionContextProvider);
|
context.callPosition, context.expressionContextProvider, context.languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,11 +106,13 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
|||||||
@NotNull StatementFilter statementFilter,
|
@NotNull StatementFilter statementFilter,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return new CallCandidateResolutionContext<>(
|
return new CallCandidateResolutionContext<>(
|
||||||
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
||||||
resolutionResultsCache, dataFlowInfoForArguments, statementFilter,
|
resolutionResultsCache, dataFlowInfoForArguments, statementFilter,
|
||||||
candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider);
|
candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider,
|
||||||
|
languageVersionSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.context;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.psi.Call;
|
import org.jetbrains.kotlin.psi.Call;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
@@ -53,10 +54,11 @@ public abstract class CallResolutionContext<Context extends CallResolutionContex
|
|||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
||||||
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider);
|
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
this.call = call;
|
this.call = call;
|
||||||
this.checkArguments = checkArguments;
|
this.checkArguments = checkArguments;
|
||||||
if (dataFlowInfoForArguments != null) {
|
if (dataFlowInfoForArguments != null) {
|
||||||
|
|||||||
+20
-13
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiFile;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||||
@@ -60,6 +61,9 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
@NotNull
|
@NotNull
|
||||||
public final CallPosition callPosition;
|
public final CallPosition callPosition;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final LanguageVersionSettings languageVersionSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for analyzing expression in the given context.
|
* Used for analyzing expression in the given context.
|
||||||
* Should be used for going through parents to find containing function, loop etc.
|
* Should be used for going through parents to find containing function, loop etc.
|
||||||
@@ -84,7 +88,8 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
@@ -98,6 +103,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
this.collectAllCandidates = collectAllCandidates;
|
this.collectAllCandidates = collectAllCandidates;
|
||||||
this.callPosition = callPosition;
|
this.callPosition = callPosition;
|
||||||
this.expressionContextProvider = expressionContextProvider;
|
this.expressionContextProvider = expressionContextProvider;
|
||||||
|
this.languageVersionSettings = languageVersionSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Context create(
|
protected abstract Context create(
|
||||||
@@ -110,7 +116,8 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
@NotNull StatementFilter statementFilter,
|
@NotNull StatementFilter statementFilter,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -123,14 +130,14 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
public Context replaceBindingTrace(@NotNull BindingTrace trace) {
|
public Context replaceBindingTrace(@NotNull BindingTrace trace) {
|
||||||
if (this.trace == trace) return self();
|
if (this.trace == trace) return self();
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceDataFlowInfo(@NotNull DataFlowInfo newDataFlowInfo) {
|
public Context replaceDataFlowInfo(@NotNull DataFlowInfo newDataFlowInfo) {
|
||||||
if (newDataFlowInfo == dataFlowInfo) return self();
|
if (newDataFlowInfo == dataFlowInfo) return self();
|
||||||
return create(trace, scope, newDataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, newDataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -138,28 +145,28 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
if (newExpectedType == null) return replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
|
if (newExpectedType == null) return replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
|
||||||
if (expectedType == newExpectedType) return self();
|
if (expectedType == newExpectedType) return self();
|
||||||
return create(trace, scope, dataFlowInfo, newExpectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, newExpectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceScope(@NotNull LexicalScope newScope) {
|
public Context replaceScope(@NotNull LexicalScope newScope) {
|
||||||
if (newScope == scope) return self();
|
if (newScope == scope) return self();
|
||||||
return create(trace, newScope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, newScope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceContextDependency(@NotNull ContextDependency newContextDependency) {
|
public Context replaceContextDependency(@NotNull ContextDependency newContextDependency) {
|
||||||
if (newContextDependency == contextDependency) return self();
|
if (newContextDependency == contextDependency) return self();
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, newContextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, newContextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceResolutionResultsCache(@NotNull ResolutionResultsCache newResolutionResultsCache) {
|
public Context replaceResolutionResultsCache(@NotNull ResolutionResultsCache newResolutionResultsCache) {
|
||||||
if (newResolutionResultsCache == resolutionResultsCache) return self();
|
if (newResolutionResultsCache == resolutionResultsCache) return self();
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, newResolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, newResolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -170,25 +177,25 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
|||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceCollectAllCandidates(boolean newCollectAllCandidates) {
|
public Context replaceCollectAllCandidates(boolean newCollectAllCandidates) {
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
newCollectAllCandidates, callPosition, expressionContextProvider);
|
newCollectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceStatementFilter(@NotNull StatementFilter statementFilter) {
|
public Context replaceStatementFilter(@NotNull StatementFilter statementFilter) {
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceCallPosition(@NotNull CallPosition callPosition) {
|
public Context replaceCallPosition(@NotNull CallPosition callPosition) {
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Context replaceExpressionContextProvider(@NotNull Function1<KtExpression, KtExpression> expressionContextProvider) {
|
public Context replaceExpressionContextProvider(@NotNull Function1<KtExpression, KtExpression> expressionContextProvider) {
|
||||||
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
+23
-13
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types.expressions;
|
|||||||
|
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.StatementFilter;
|
import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||||
@@ -33,9 +34,10 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull KotlinType expectedType
|
@NotNull KotlinType expectedType,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE);
|
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -45,10 +47,11 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull KotlinType expectedType,
|
@NotNull KotlinType expectedType,
|
||||||
@NotNull ContextDependency contextDependency,
|
@NotNull ContextDependency contextDependency,
|
||||||
@NotNull StatementFilter statementFilter
|
@NotNull StatementFilter statementFilter,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return newContext(trace, scope, dataFlowInfo, expectedType, contextDependency,
|
return newContext(trace, scope, dataFlowInfo, expectedType, contextDependency,
|
||||||
new ResolutionResultsCacheImpl(), statementFilter, false);
|
new ResolutionResultsCacheImpl(), statementFilter, false, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -58,7 +61,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
context.contextDependency, context.resolutionResultsCache,
|
context.contextDependency, context.resolutionResultsCache,
|
||||||
context.statementFilter,
|
context.statementFilter,
|
||||||
context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates,
|
||||||
context.callPosition, context.expressionContextProvider);
|
context.callPosition, context.expressionContextProvider, context.languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -68,7 +71,8 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
context.contextDependency, context.resolutionResultsCache,
|
context.contextDependency, context.resolutionResultsCache,
|
||||||
context.statementFilter,
|
context.statementFilter,
|
||||||
context.isAnnotationContext, isDebuggerContext, context.collectAllCandidates,
|
context.isAnnotationContext, isDebuggerContext, context.collectAllCandidates,
|
||||||
context.callPosition, context.expressionContextProvider);
|
context.callPosition, context.expressionContextProvider,
|
||||||
|
context.languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -80,11 +84,13 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull ContextDependency contextDependency,
|
@NotNull ContextDependency contextDependency,
|
||||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||||
@NotNull StatementFilter statementFilter,
|
@NotNull StatementFilter statementFilter,
|
||||||
boolean isAnnotationContext
|
boolean isAnnotationContext,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return new ExpressionTypingContext(
|
return new ExpressionTypingContext(
|
||||||
trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache,
|
trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache,
|
||||||
statementFilter, isAnnotationContext, false, false, CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER);
|
statementFilter, isAnnotationContext, false, false,
|
||||||
|
CallPosition.Unknown.INSTANCE, DEFAULT_EXPRESSION_CONTEXT_PROVIDER, languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExpressionTypingContext(
|
private ExpressionTypingContext(
|
||||||
@@ -99,10 +105,12 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache,
|
||||||
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider);
|
statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider,
|
||||||
|
languageVersionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,11 +124,13 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull StatementFilter statementFilter,
|
@NotNull StatementFilter statementFilter,
|
||||||
boolean collectAllCandidates,
|
boolean collectAllCandidates,
|
||||||
@NotNull CallPosition callPosition,
|
@NotNull CallPosition callPosition,
|
||||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider,
|
||||||
|
@NotNull LanguageVersionSettings languageVersionSettings
|
||||||
) {
|
) {
|
||||||
return new ExpressionTypingContext(trace, scope, dataFlowInfo,
|
return new ExpressionTypingContext(trace, scope, dataFlowInfo,
|
||||||
expectedType, contextDependency, resolutionResultsCache,
|
expectedType, contextDependency, resolutionResultsCache,
|
||||||
statementFilter, isAnnotationContext, isDebuggerContext,
|
statementFilter, isAnnotationContext, isDebuggerContext,
|
||||||
collectAllCandidates, callPosition, expressionContextProvider);
|
collectAllCandidates, callPosition, expressionContextProvider,
|
||||||
|
languageVersionSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -114,7 +114,7 @@ public class ExpressionTypingServices {
|
|||||||
@NotNull ContextDependency contextDependency
|
@NotNull ContextDependency contextDependency
|
||||||
) {
|
) {
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter
|
trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter, getLanguageVersionSettings()
|
||||||
);
|
);
|
||||||
if (contextExpression != expression) {
|
if (contextExpression != expression) {
|
||||||
context = context.replaceExpressionContextProvider(arg -> arg == expression ? contextExpression : null);
|
context = context.replaceExpressionContextProvider(arg -> arg == expression ? contextExpression : null);
|
||||||
@@ -156,7 +156,7 @@ public class ExpressionTypingServices {
|
|||||||
}
|
}
|
||||||
checkFunctionReturnType(function, ExpressionTypingContext.newContext(
|
checkFunctionReturnType(function, ExpressionTypingContext.newContext(
|
||||||
trace,
|
trace,
|
||||||
functionInnerScope, dataFlowInfo, expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE
|
functionInnerScope, dataFlowInfo, expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE, getLanguageVersionSettings()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ public class ExpressionTypingServices {
|
|||||||
expressionTypingComponents.overloadChecker);
|
expressionTypingComponents.overloadChecker);
|
||||||
|
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE
|
trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE, getLanguageVersionSettings()
|
||||||
);
|
);
|
||||||
KotlinTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody());
|
KotlinTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody());
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.types.expressions
|
package org.jetbrains.kotlin.types.expressions
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
@@ -32,7 +33,8 @@ import org.jetbrains.kotlin.types.TypeUtils
|
|||||||
|
|
||||||
class ValueParameterResolver(
|
class ValueParameterResolver(
|
||||||
private val expressionTypingServices: ExpressionTypingServices,
|
private val expressionTypingServices: ExpressionTypingServices,
|
||||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator
|
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||||
|
private val languageVersionSettings: LanguageVersionSettings
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun resolveValueParameters(
|
fun resolveValueParameters(
|
||||||
@@ -44,7 +46,8 @@ class ValueParameterResolver(
|
|||||||
) {
|
) {
|
||||||
val scopeForDefaultValue = LexicalScopeImpl(declaringScope, declaringScope.ownerDescriptor, false, null, LexicalScopeKind.DEFAULT_VALUE)
|
val scopeForDefaultValue = LexicalScopeImpl(declaringScope, declaringScope.ownerDescriptor, false, null, LexicalScopeKind.DEFAULT_VALUE)
|
||||||
|
|
||||||
val contextForDefaultValue = ExpressionTypingContext.newContext(trace, scopeForDefaultValue, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE)
|
val contextForDefaultValue = ExpressionTypingContext.newContext(trace, scopeForDefaultValue, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE,
|
||||||
|
languageVersionSettings)
|
||||||
|
|
||||||
for ((descriptor, parameter) in valueParameterDescriptors.zip(valueParameters)) {
|
for ((descriptor, parameter) in valueParameterDescriptors.zip(valueParameters)) {
|
||||||
ForceResolveUtil.forceResolveAllContents(descriptor.annotations)
|
ForceResolveUtil.forceResolveAllContents(descriptor.annotations)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns;
|
import org.jetbrains.kotlin.builtins.DefaultBuiltIns;
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||||
|
import org.jetbrains.kotlin.config.CommonConfigurationKeysKt;
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||||
@@ -60,12 +62,14 @@ public class ExpectedResolveDataUtil {
|
|||||||
KotlinBuiltIns builtIns = DefaultBuiltIns.getInstance();
|
KotlinBuiltIns builtIns = DefaultBuiltIns.getInstance();
|
||||||
|
|
||||||
Map<String, DeclarationDescriptor> nameToDescriptor = new HashMap<>();
|
Map<String, DeclarationDescriptor> nameToDescriptor = new HashMap<>();
|
||||||
nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(builtIns.getInt(), "plus", project, builtIns.getIntType()));
|
nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(builtIns.getInt(), "plus", project, environment, builtIns.getIntType()));
|
||||||
FunctionDescriptor descriptorForGet = standardFunction(builtIns.getArray(), "get", project, builtIns.getIntType());
|
FunctionDescriptor descriptorForGet = standardFunction(builtIns.getArray(), "get", project, environment, builtIns.getIntType());
|
||||||
nameToDescriptor.put("kotlin::Array.get(Int)", descriptorForGet.getOriginal());
|
nameToDescriptor.put("kotlin::Array.get(Int)", descriptorForGet.getOriginal());
|
||||||
nameToDescriptor.put("kotlin::Int.compareTo(Double)", standardFunction(builtIns.getInt(), "compareTo", project, builtIns.getDoubleType()));
|
nameToDescriptor.put("kotlin::Int.compareTo(Double)",
|
||||||
|
standardFunction(builtIns.getInt(), "compareTo", project, environment, builtIns.getDoubleType()));
|
||||||
@NotNull
|
@NotNull
|
||||||
FunctionDescriptor descriptorForSet = standardFunction(builtIns.getArray(), "set", project, builtIns.getIntType(), builtIns.getIntType());
|
FunctionDescriptor descriptorForSet = standardFunction(builtIns.getArray(), "set", project, environment,
|
||||||
|
builtIns.getIntType(), builtIns.getIntType());
|
||||||
nameToDescriptor.put("kotlin::Array.set(Int, Int)", descriptorForSet.getOriginal());
|
nameToDescriptor.put("kotlin::Array.set(Int, Int)", descriptorForSet.getOriginal());
|
||||||
|
|
||||||
return nameToDescriptor;
|
return nameToDescriptor;
|
||||||
@@ -135,6 +139,7 @@ public class ExpectedResolveDataUtil {
|
|||||||
ClassDescriptor classDescriptor,
|
ClassDescriptor classDescriptor,
|
||||||
String name,
|
String name,
|
||||||
Project project,
|
Project project,
|
||||||
|
KotlinCoreEnvironment environment,
|
||||||
KotlinType... parameterTypes
|
KotlinType... parameterTypes
|
||||||
) {
|
) {
|
||||||
ModuleDescriptorImpl emptyModule = KotlinTestUtils.createEmptyModule();
|
ModuleDescriptorImpl emptyModule = KotlinTestUtils.createEmptyModule();
|
||||||
@@ -146,9 +151,10 @@ public class ExpectedResolveDataUtil {
|
|||||||
classDescriptor.getThisAsReceiverParameter(),
|
classDescriptor.getThisAsReceiverParameter(),
|
||||||
LexicalScopeKind.SYNTHETIC);
|
LexicalScopeKind.SYNTHETIC);
|
||||||
|
|
||||||
|
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(environment.getConfiguration());
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
new BindingTraceContext(), lexicalScope,
|
new BindingTraceContext(), lexicalScope,
|
||||||
DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE, languageVersionSettings);
|
||||||
|
|
||||||
KtExpression callElement = KtPsiFactory(project).createExpression(name);
|
KtExpression callElement = KtPsiFactory(project).createExpression(name);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.idea.resolve.frontendService
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter
|
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
||||||
import org.jetbrains.kotlin.resolve.calls.CallResolver
|
import org.jetbrains.kotlin.resolve.calls.CallResolver
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
@@ -203,7 +202,7 @@ class ShadowedDeclarationsFilter(
|
|||||||
val dataFlowInfo = bindingContext.getDataFlowInfoBefore(context)
|
val dataFlowInfo = bindingContext.getDataFlowInfoBefore(context)
|
||||||
val context = BasicCallResolutionContext.create(bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo,
|
val context = BasicCallResolutionContext.create(bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo,
|
||||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
false)
|
false, resolutionFacade.frontendService())
|
||||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||||
val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context)
|
val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context)
|
||||||
val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor }
|
val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor }
|
||||||
|
|||||||
+2
-1
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.lightClasses.IDELightClassConstr
|
|||||||
import org.jetbrains.kotlin.idea.compiler.IDELanguageSettingsProvider
|
import org.jetbrains.kotlin.idea.compiler.IDELanguageSettingsProvider
|
||||||
import org.jetbrains.kotlin.idea.project.IdeaEnvironment
|
import org.jetbrains.kotlin.idea.project.IdeaEnvironment
|
||||||
import org.jetbrains.kotlin.idea.project.ResolveElementCache
|
import org.jetbrains.kotlin.idea.project.ResolveElementCache
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.stubindex.KotlinOverridableInternalMembersShortNameIndex
|
import org.jetbrains.kotlin.idea.stubindex.KotlinOverridableInternalMembersShortNameIndex
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
@@ -364,7 +365,7 @@ object IDELightClassContexts {
|
|||||||
BasicCallResolutionContext.create(
|
BasicCallResolutionContext.create(
|
||||||
trace, scope, CallMaker.makeCall(null, null, annotationEntry), TypeUtils.NO_EXPECTED_TYPE,
|
trace, scope, CallMaker.makeCall(null, null, annotationEntry), TypeUtils.NO_EXPECTED_TYPE,
|
||||||
DataFlowInfoFactory.EMPTY, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
DataFlowInfoFactory.EMPTY, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
true
|
true, annotationEntry.languageVersionSettings
|
||||||
),
|
),
|
||||||
annotationEntry.calleeExpression!!.constructorReferenceExpression!!,
|
annotationEntry.calleeExpression!!.constructorReferenceExpression!!,
|
||||||
annotationConstructor.returnType
|
annotationConstructor.returnType
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.core
|
|||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.util.FuzzyType
|
import org.jetbrains.kotlin.idea.util.FuzzyType
|
||||||
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
@@ -75,7 +76,8 @@ class IterableTypesDetection(
|
|||||||
if (!canBeIterable(type)) return null
|
if (!canBeIterable(type)) return null
|
||||||
|
|
||||||
val expression = KtPsiFactory(project).createExpression("fake")
|
val expression = KtPsiFactory(project).createExpression("fake")
|
||||||
val context = ExpressionTypingContext.newContext(BindingTraceContext(), scope, DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE)
|
val context = ExpressionTypingContext.newContext(
|
||||||
|
BindingTraceContext(), scope, DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE, expression.languageVersionSettings)
|
||||||
val expressionReceiver = ExpressionReceiver.create(expression, type.type, context.trace.bindingContext)
|
val expressionReceiver = ExpressionReceiver.create(expression, type.type, context.trace.bindingContext)
|
||||||
val elementType = forLoopConventionsChecker.checkIterableConvention(expressionReceiver, context)
|
val elementType = forLoopConventionsChecker.checkIterableConvention(expressionReceiver, context)
|
||||||
return elementType?.let { it.toFuzzyType(type.freeParameters) }
|
return elementType?.let { it.toFuzzyType(type.freeParameters) }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.idea.analysis.computeTypeInContext
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.references.mainReference
|
import org.jetbrains.kotlin.idea.references.mainReference
|
||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||||
@@ -121,7 +122,7 @@ fun Call.resolveCandidates(
|
|||||||
val callResolutionContext = BasicCallResolutionContext.create(
|
val callResolutionContext = BasicCallResolutionContext.create(
|
||||||
bindingTrace, resolutionScope, this, expectedType, dataFlowInfo,
|
bindingTrace, resolutionScope, this, expectedType, dataFlowInfo,
|
||||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
false
|
false, callElement.languageVersionSettings
|
||||||
).replaceCollectAllCandidates(true)
|
).replaceCollectAllCandidates(true)
|
||||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.idea.core.NotPropertiesService
|
|||||||
import org.jetbrains.kotlin.idea.core.copied
|
import org.jetbrains.kotlin.idea.core.copied
|
||||||
import org.jetbrains.kotlin.idea.core.replaced
|
import org.jetbrains.kotlin.idea.core.replaced
|
||||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||||
@@ -205,7 +206,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
|||||||
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace")
|
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace")
|
||||||
val context = BasicCallResolutionContext.create(bindingTrace, resolutionScope, newCall, expectedType, dataFlowInfo,
|
val context = BasicCallResolutionContext.create(bindingTrace, resolutionScope, newCall, expectedType, dataFlowInfo,
|
||||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||||
false)
|
false, resolvedCall.call.callElement.languageVersionSettings)
|
||||||
val callResolver = facade.frontendService<CallResolver>()
|
val callResolver = facade.frontendService<CallResolver>()
|
||||||
val result = callResolver.resolveSimpleProperty(context)
|
val result = callResolver.resolveSimpleProperty(context)
|
||||||
return result.isSuccess && result.resultingDescriptor.original == property
|
return result.isSuccess && result.resultingDescriptor.original == property
|
||||||
|
|||||||
Reference in New Issue
Block a user