From b1d9abdf83e2813ed272d311eb548d6380e2c07b Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 12 Sep 2017 17:25:50 +0300 Subject: [PATCH] Propagate `languageVersionSettings` to resolution context --- .../resolve/DelegatedPropertyResolver.kt | 7 ++-- .../kotlin/resolve/DescriptorResolver.java | 4 +-- .../kotlin/resolve/calls/CallResolver.java | 5 +-- .../context/BasicCallResolutionContext.java | 22 +++++++----- .../CallCandidateResolutionContext.java | 18 ++++++---- .../calls/context/CallResolutionContext.java | 8 +++-- .../calls/context/ResolutionContext.java | 33 ++++++++++------- .../expressions/ExpressionTypingContext.java | 36 ++++++++++++------- .../expressions/ExpressionTypingServices.java | 8 ++--- .../expressions/ValueParameterResolver.kt | 7 ++-- .../resolve/ExpectedResolveDataUtil.java | 18 ++++++---- .../idea/util/ShadowedDeclarationsFilter.kt | 5 ++- .../lightClasses/IDELightClassContexts.kt | 3 +- .../idea/core/IterableTypesDetection.kt | 6 ++-- .../org/jetbrains/kotlin/idea/core/Utils.kt | 5 +-- .../UsePropertyAccessSyntaxIntention.kt | 5 +-- 16 files changed, 116 insertions(+), 74 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt index 3352bc976fc..c31634a2c8e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt @@ -304,7 +304,7 @@ class DelegatedPropertyResolver( else 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 @@ -339,7 +339,7 @@ class DelegatedPropertyResolver( initializerScope: LexicalScope, dataFlowInfo: DataFlowInfo ): OverloadResolutionResults { - 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) } @@ -537,7 +537,8 @@ class DelegatedPropertyResolver( traceToResolveConventionMethods, false, delegateExpression, ContextDependency.DEPENDENT) 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( variableDescriptor, delegateExpression, delegateType.type ?: return null, contextForProvideDelegate diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index a9789071142..a4fa9a24d87 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -337,7 +337,7 @@ public class DescriptorResolver { scope, destructuringDeclaration, new TransientReceiver(type), /* initializer = */ null, 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(); ExpressionTypingContext context = ExpressionTypingContext.newContext( - trace, scopeForDeclarationResolution, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE + trace, scopeForDeclarationResolution, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, languageVersionSettings ); ExpressionReceiver receiver = createReceiverForDestructuringDeclaration(destructuringDeclaration, context); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 56ac8c60209..8250ad550a3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -303,7 +303,7 @@ public class CallResolver { return resolveFunctionCall( BasicCallResolutionContext.create( 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), NO_EXPECTED_TYPE, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - false); + false, + languageVersionSettings); if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java index 9a318482a37..6fc61856d21 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java @@ -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"); * 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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.psi.Call; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.BindingTrace; @@ -44,11 +45,12 @@ public class BasicCallResolutionContext extends CallResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, - callPosition, expressionContextProvider); + callPosition, expressionContextProvider, languageVersionSettings); } @NotNull @@ -60,12 +62,13 @@ public class BasicCallResolutionContext extends CallResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { return new BasicCallResolutionContext( trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, - callPosition, expressionContextProvider); + callPosition, expressionContextProvider, languageVersionSettings); } @NotNull @@ -111,6 +115,6 @@ public class BasicCallResolutionContext extends CallResolutionContext boolean isDebuggerContext, boolean collectAllCandidates, @NotNull CallPosition callPosition, - @NotNull Function1 expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, statementFilter, isAnnotationContext, isDebuggerContext, - collectAllCandidates, callPosition, expressionContextProvider); + collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings); this.candidateCall = candidateCall; this.tracing = tracing; this.candidateResolveMode = candidateResolveMode; @@ -78,7 +80,7 @@ public final class CallCandidateResolutionContext context.resolutionResultsCache, context.dataFlowInfoForArguments, context.statementFilter, candidateResolveMode, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates, - context.callPosition, context.expressionContextProvider); + context.callPosition, context.expressionContextProvider, context.languageVersionSettings); } @NotNull @@ -90,7 +92,7 @@ public final class CallCandidateResolutionContext 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.callPosition, context.expressionContextProvider, context.languageVersionSettings); } @Override @@ -104,11 +106,13 @@ public final class CallCandidateResolutionContext @NotNull StatementFilter statementFilter, boolean collectAllCandidates, @NotNull CallPosition callPosition, - @NotNull Function1 expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { return new CallCandidateResolutionContext<>( candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, statementFilter, - candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider); + candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider, + languageVersionSettings); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java index c5ec7d0840e..affdd873e56 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java @@ -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"); * 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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.psi.Call; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.BindingTrace; @@ -53,10 +54,11 @@ public abstract class CallResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache, - statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider); + statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings); this.call = call; this.checkArguments = checkArguments; if (dataFlowInfoForArguments != null) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/ResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/ResolutionContext.java index 8bae292700f..82f90579bfb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/ResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/ResolutionContext.java @@ -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"); * 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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.StatementFilter; @@ -60,6 +61,9 @@ public abstract class ResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { this.trace = trace; this.scope = scope; @@ -98,6 +103,7 @@ public abstract class ResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ); @NotNull @@ -123,14 +130,14 @@ public abstract class ResolutionContext expressionContextProvider) { return create(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter, - collectAllCandidates, callPosition, expressionContextProvider); + collectAllCandidates, callPosition, expressionContextProvider, languageVersionSettings); } @Nullable diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java index a339d2cd1a6..5c418cfe0b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java @@ -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"); * 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 org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.StatementFilter; @@ -33,9 +34,10 @@ public class ExpressionTypingContext extends ResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache, - statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider); + statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider, + languageVersionSettings); } @Override @@ -116,11 +124,13 @@ public class ExpressionTypingContext extends ResolutionContext expressionContextProvider + @NotNull Function1 expressionContextProvider, + @NotNull LanguageVersionSettings languageVersionSettings ) { return new ExpressionTypingContext(trace, scope, dataFlowInfo, expectedType, contextDependency, resolutionResultsCache, statementFilter, isAnnotationContext, isDebuggerContext, - collectAllCandidates, callPosition, expressionContextProvider); + collectAllCandidates, callPosition, expressionContextProvider, + languageVersionSettings); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java index 542ef78086c..8ebe59281bd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java @@ -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"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ public class ExpressionTypingServices { @NotNull ContextDependency contextDependency ) { ExpressionTypingContext context = ExpressionTypingContext.newContext( - trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter + trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter, getLanguageVersionSettings() ); if (contextExpression != expression) { context = context.replaceExpressionContextProvider(arg -> arg == expression ? contextExpression : null); @@ -156,7 +156,7 @@ public class ExpressionTypingServices { } checkFunctionReturnType(function, ExpressionTypingContext.newContext( 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); 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()); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt index 22b9f2bbb29..e7a5900dc7e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.types.expressions +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.psi.KtParameter @@ -32,7 +33,8 @@ import org.jetbrains.kotlin.types.TypeUtils class ValueParameterResolver( private val expressionTypingServices: ExpressionTypingServices, - private val constantExpressionEvaluator: ConstantExpressionEvaluator + private val constantExpressionEvaluator: ConstantExpressionEvaluator, + private val languageVersionSettings: LanguageVersionSettings ) { fun resolveValueParameters( @@ -44,7 +46,8 @@ class ValueParameterResolver( ) { 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)) { ForceResolveUtil.forceResolveAllContents(descriptor.annotations) diff --git a/compiler/tests-common/org/jetbrains/kotlin/resolve/ExpectedResolveDataUtil.java b/compiler/tests-common/org/jetbrains/kotlin/resolve/ExpectedResolveDataUtil.java index 6cd04e1cc79..21a5a706f8e 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/resolve/ExpectedResolveDataUtil.java +++ b/compiler/tests-common/org/jetbrains/kotlin/resolve/ExpectedResolveDataUtil.java @@ -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"); * 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.KotlinBuiltIns; 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.impl.ModuleDescriptorImpl; import org.jetbrains.kotlin.incremental.components.NoLookupLocation; @@ -60,12 +62,14 @@ public class ExpectedResolveDataUtil { KotlinBuiltIns builtIns = DefaultBuiltIns.getInstance(); Map nameToDescriptor = new HashMap<>(); - nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(builtIns.getInt(), "plus", project, builtIns.getIntType())); - FunctionDescriptor descriptorForGet = standardFunction(builtIns.getArray(), "get", project, builtIns.getIntType()); + nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(builtIns.getInt(), "plus", project, environment, builtIns.getIntType())); + FunctionDescriptor descriptorForGet = standardFunction(builtIns.getArray(), "get", project, environment, builtIns.getIntType()); 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 - 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()); return nameToDescriptor; @@ -135,6 +139,7 @@ public class ExpectedResolveDataUtil { ClassDescriptor classDescriptor, String name, Project project, + KotlinCoreEnvironment environment, KotlinType... parameterTypes ) { ModuleDescriptorImpl emptyModule = KotlinTestUtils.createEmptyModule(); @@ -146,9 +151,10 @@ public class ExpectedResolveDataUtil { classDescriptor.getThisAsReceiverParameter(), LexicalScopeKind.SYNTHETIC); + LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(environment.getConfiguration()); ExpressionTypingContext context = ExpressionTypingContext.newContext( new BindingTraceContext(), lexicalScope, - DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE); + DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE, languageVersionSettings); KtExpression callElement = KtPsiFactory(project).createExpression(name); diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt index e40123c4485..9e9d38b9b92 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt @@ -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"); * 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.resolve.BindingContext 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.calls.CallResolver import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext @@ -203,7 +202,7 @@ class ShadowedDeclarationsFilter( val dataFlowInfo = bindingContext.getDataFlowInfoBefore(context) val context = BasicCallResolutionContext.create(bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - false) + false, resolutionFacade.frontendService()) val callResolver = resolutionFacade.frontendService() val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context) val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt index d6c182fcb96..0694e86aff3 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt @@ -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.project.IdeaEnvironment 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.incremental.components.LookupTracker import org.jetbrains.kotlin.incremental.components.NoLookupLocation @@ -364,7 +365,7 @@ object IDELightClassContexts { BasicCallResolutionContext.create( trace, scope, CallMaker.makeCall(null, null, annotationEntry), TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - true + true, annotationEntry.languageVersionSettings ), annotationEntry.calleeExpression!!.constructorReferenceExpression!!, annotationConstructor.returnType diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt index 22270da3a80..f1d1dde073e 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt @@ -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"); * 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 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.toFuzzyType import org.jetbrains.kotlin.incremental.components.NoLookupLocation @@ -75,7 +76,8 @@ class IterableTypesDetection( if (!canBeIterable(type)) return null 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 elementType = forLoopConventionsChecker.checkIterableConvention(expressionReceiver, context) return elementType?.let { it.toFuzzyType(type.freeParameters) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt index 6a99d7b2ec2..0b25fb6eb14 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt @@ -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"); * 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.getResolutionFacade 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.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.resolve.frontendService @@ -121,7 +122,7 @@ fun Call.resolveCandidates( val callResolutionContext = BasicCallResolutionContext.create( bindingTrace, resolutionScope, this, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - false + false, callElement.languageVersionSettings ).replaceCollectAllCandidates(true) val callResolver = resolutionFacade.frontendService() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 13c985ee1b1..1d68ac88268 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -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"); * 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.replaced 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.frontendService import org.jetbrains.kotlin.idea.util.getResolutionScope @@ -205,7 +206,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace") val context = BasicCallResolutionContext.create(bindingTrace, resolutionScope, newCall, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - false) + false, resolvedCall.call.callElement.languageVersionSettings) val callResolver = facade.frontendService() val result = callResolver.resolveSimpleProperty(context) return result.isSuccess && result.resultingDescriptor.original == property