Rename LanguageFeatureSettings -> LanguageVersionSettings
This commit is contained in:
@@ -249,7 +249,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
if (arguments.languageVersion != null) {
|
||||
LanguageVersion languageVersion = LanguageVersion.fromVersionString(arguments.languageVersion);
|
||||
if (languageVersion != null) {
|
||||
configuration.put(CommonConfigurationKeys.LANGUAGE_FEATURE_SETTINGS, new LanguageVersionSettingsImpl(languageVersion));
|
||||
configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, new LanguageVersionSettingsImpl(languageVersion));
|
||||
}
|
||||
else {
|
||||
List<String> versionStrings = ArraysKt.map(LanguageVersion.values(), new Function1<LanguageVersion, String>() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.frontend.java.di
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.*
|
||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
@@ -46,7 +46,7 @@ fun StorageComponentContainer.configureJavaTopDownAnalysis(
|
||||
moduleContentScope: GlobalSearchScope,
|
||||
project: Project,
|
||||
lookupTracker: LookupTracker,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
useInstance(moduleContentScope)
|
||||
useInstance(lookupTracker)
|
||||
@@ -72,7 +72,7 @@ fun StorageComponentContainer.configureJavaTopDownAnalysis(
|
||||
useImpl<JavaLazyAnalyzerPostConstruct>()
|
||||
useInstance(InternalFlexibleTypeTransformer)
|
||||
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
}
|
||||
|
||||
fun createContainerForLazyResolveWithJava(
|
||||
@@ -83,14 +83,14 @@ fun createContainerForLazyResolveWithJava(
|
||||
moduleClassResolver: ModuleClassResolver,
|
||||
targetEnvironment: TargetEnvironment = CompilerEnvironment,
|
||||
packagePartProvider: PackagePartProvider,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): ComponentProvider = createContainer("LazyResolveWithJava") {
|
||||
//TODO: idea specific code
|
||||
useInstance(packagePartProvider)
|
||||
|
||||
configureModule(moduleContext, JvmPlatform, bindingTrace)
|
||||
|
||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, LookupTracker.DO_NOTHING, languageFeatureSettings)
|
||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, LookupTracker.DO_NOTHING, languageVersionSettings)
|
||||
|
||||
useInstance(moduleClassResolver)
|
||||
|
||||
@@ -111,12 +111,12 @@ fun createContainerForTopDownAnalyzerForJvm(
|
||||
moduleContentScope: GlobalSearchScope,
|
||||
lookupTracker: LookupTracker,
|
||||
packagePartProvider: PackagePartProvider,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): ContainerForTopDownAnalyzerForJvm = createContainer("TopDownAnalyzerForJvm") {
|
||||
useInstance(packagePartProvider)
|
||||
|
||||
configureModule(moduleContext, JvmPlatform, bindingTrace)
|
||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker, languageFeatureSettings)
|
||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker, languageVersionSettings)
|
||||
|
||||
useInstance(declarationProviderFactory)
|
||||
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
GlobalSearchScope.allScope(project),
|
||||
lookupTracker,
|
||||
packagePartProvider,
|
||||
configuration.get(CommonConfigurationKeys.LANGUAGE_FEATURE_SETTINGS, LanguageVersionSettingsImpl.DEFAULT)
|
||||
configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT)
|
||||
);
|
||||
|
||||
List<PackageFragmentProvider> additionalProviders = new ArrayList<PackageFragmentProvider>();
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequenc
|
||||
|
||||
object AdditionalBuiltInsMembersCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
if (context.languageFeatureSettings.supportsFeature(LanguageFeature.AdditionalBuiltInsMembers)) return
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.AdditionalBuiltInsMembers)) return
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor as? CallableMemberDescriptor ?: return
|
||||
|
||||
reportErrorIfAdditionalBuiltinDescriptor(resultingDescriptor, context.trace, reportOn)
|
||||
@@ -49,9 +49,9 @@ object AdditionalBuiltInsMemberOverrideDeclarationChecker : DeclarationChecker {
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
if (languageFeatureSettings.supportsFeature(LanguageFeature.AdditionalBuiltInsMembers)) return
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.AdditionalBuiltInsMembers)) return
|
||||
val resultingDescriptor = descriptor as? CallableMemberDescriptor ?: return
|
||||
val overrideKeyword = declaration.modifierList?.getModifier(KtTokens.OVERRIDE_KEYWORD) ?: return
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public class CommonConfigurationKeys {
|
||||
private CommonConfigurationKeys() {
|
||||
}
|
||||
|
||||
public static final CompilerConfigurationKey<LanguageFeatureSettings> LANGUAGE_FEATURE_SETTINGS =
|
||||
CompilerConfigurationKey.create("language feature settings");
|
||||
public static final CompilerConfigurationKey<LanguageVersionSettings> LANGUAGE_VERSION_SETTINGS =
|
||||
CompilerConfigurationKey.create("language version settings");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> DISABLE_INLINE =
|
||||
CompilerConfigurationKey.create("disable inline");
|
||||
|
||||
+2
-2
@@ -49,11 +49,11 @@ enum class LanguageVersion(val versionString: String) {
|
||||
}
|
||||
}
|
||||
|
||||
interface LanguageFeatureSettings {
|
||||
interface LanguageVersionSettings {
|
||||
fun supportsFeature(feature: LanguageFeature): Boolean
|
||||
}
|
||||
|
||||
class LanguageVersionSettingsImpl(private val languageVersion: LanguageVersion) : LanguageFeatureSettings {
|
||||
class LanguageVersionSettingsImpl(private val languageVersion: LanguageVersion) : LanguageVersionSettings {
|
||||
override fun supportsFeature(feature: LanguageFeature): Boolean {
|
||||
return languageVersion.ordinal >= feature.sinceVersion.ordinal
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.frontend.di
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.*
|
||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
@@ -66,7 +66,7 @@ fun createContainerForBodyResolve(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
statementFilter: StatementFilter,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): StorageComponentContainer = createContainer("BodyResolve") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
|
||||
@@ -74,7 +74,7 @@ fun createContainerForBodyResolve(
|
||||
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(BodyResolveCache.ThrowException)
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
|
||||
useImpl<BodyResolver>()
|
||||
}
|
||||
@@ -85,7 +85,7 @@ fun createContainerForLazyBodyResolve(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
bodyResolveCache: BodyResolveCache,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): StorageComponentContainer = createContainer("LazyBodyResolve") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
|
||||
@@ -93,7 +93,7 @@ fun createContainerForLazyBodyResolve(
|
||||
useInstance(kotlinCodeAnalyzer)
|
||||
useInstance(kotlinCodeAnalyzer.fileScopeProvider)
|
||||
useInstance(bodyResolveCache)
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
||||
useImpl<BasicAbsentDescriptorHandler>()
|
||||
}
|
||||
@@ -103,7 +103,7 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
lookupTracker: LookupTracker,
|
||||
languageFeatureSettings: LanguageFeatureSettings,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
localClassDescriptorHolder: LocalClassDescriptorHolder
|
||||
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
@@ -122,7 +122,7 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
||||
useImpl<DeclarationScopeProviderForLocalClassifierAnalyzer>()
|
||||
useImpl<LocalLazyDeclarationResolver>()
|
||||
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
}
|
||||
|
||||
fun createContainerForLazyResolve(
|
||||
@@ -131,13 +131,13 @@ fun createContainerForLazyResolve(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
targetEnvironment: TargetEnvironment,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): StorageComponentContainer = createContainer("LazyResolve") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
|
||||
useInstance(declarationProviderFactory)
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
|
||||
useImpl<FileScopeProviderImpl>()
|
||||
targetEnvironment.configure(this)
|
||||
@@ -152,8 +152,8 @@ fun createLazyResolveSession(
|
||||
declarationProviderFactory: DeclarationProviderFactory,
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
languageFeatureSettings: LanguageFeatureSettings,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
targetEnvironment: TargetEnvironment = CompilerEnvironment
|
||||
): ResolveSession = createContainerForLazyResolve(
|
||||
moduleContext, declarationProviderFactory, bindingTrace, platform, targetEnvironment, languageFeatureSettings
|
||||
moduleContext, declarationProviderFactory, bindingTrace, platform, targetEnvironment, languageVersionSettings
|
||||
).get<ResolveSession>()
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
@@ -71,7 +71,7 @@ public class BodyResolver {
|
||||
@NotNull private final BodyResolveCache bodyResolveCache;
|
||||
@NotNull private final KotlinBuiltIns builtIns;
|
||||
@NotNull private final OverloadChecker overloadChecker;
|
||||
@NotNull private final LanguageFeatureSettings languageFeatureSettings;
|
||||
@NotNull private final LanguageVersionSettings languageVersionSettings;
|
||||
|
||||
public BodyResolver(
|
||||
@NotNull AnnotationResolver annotationResolver,
|
||||
@@ -87,7 +87,7 @@ public class BodyResolver {
|
||||
@NotNull AnnotationChecker annotationChecker,
|
||||
@NotNull KotlinBuiltIns builtIns,
|
||||
@NotNull OverloadChecker overloadChecker,
|
||||
@NotNull LanguageFeatureSettings languageFeatureSettings
|
||||
@NotNull LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
this.annotationResolver = annotationResolver;
|
||||
this.bodyResolveCache = bodyResolveCache;
|
||||
@@ -102,7 +102,7 @@ public class BodyResolver {
|
||||
this.trace = new ObservableBindingTrace(trace);
|
||||
this.valueParameterResolver = valueParameterResolver;
|
||||
this.builtIns = builtIns;
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
}
|
||||
|
||||
private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext c) {
|
||||
@@ -400,7 +400,7 @@ public class BodyResolver {
|
||||
if (ktClassOrObject instanceof KtEnumEntry) {
|
||||
parentEnumOrSealed = Collections.singleton(((ClassDescriptor) descriptor.getContainingDeclaration()).getTypeConstructor());
|
||||
}
|
||||
else if (languageFeatureSettings.supportsFeature(TopLevelSealedInheritance) && DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
else if (languageVersionSettings.supportsFeature(TopLevelSealedInheritance) && DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
// TODO: improve diagnostic when top level sealed inheritance is disabled
|
||||
for (KotlinType supertype : supertypes.values()) {
|
||||
ClassifierDescriptor classifierDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||
@@ -477,7 +477,7 @@ public class BodyResolver {
|
||||
addSupertype = false;
|
||||
}
|
||||
else if (ktClassOrObject.hasModifier(KtTokens.DATA_KEYWORD) &&
|
||||
!languageFeatureSettings.supportsFeature(LanguageFeature.DataClassInheritance)) {
|
||||
!languageVersionSettings.supportsFeature(LanguageFeature.DataClassInheritance)) {
|
||||
trace.report(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES.on(typeReference));
|
||||
addSupertype = false;
|
||||
}
|
||||
@@ -560,7 +560,7 @@ public class BodyResolver {
|
||||
|
||||
private void processModifiersOnInitializer(@NotNull KtModifierListOwner owner, @NotNull LexicalScope scope) {
|
||||
annotationChecker.check(owner, trace, null);
|
||||
ModifierCheckerCore.INSTANCE.check(owner, trace, null, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(owner, trace, null, languageVersionSettings);
|
||||
KtModifierList modifierList = owner.getModifierList();
|
||||
if (modifierList == null) return;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
@@ -28,7 +28,7 @@ interface DeclarationChecker {
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ interface SimpleDeclarationChecker : DeclarationChecker {
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext, languageFeatureSettings: LanguageFeatureSettings
|
||||
bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings
|
||||
) = check(declaration, descriptor, diagnosticHolder, bindingContext)
|
||||
|
||||
fun check(
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet
|
||||
import com.google.common.collect.Sets
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
||||
@@ -73,10 +73,10 @@ internal class DeclarationsCheckerBuilder(
|
||||
private val originalModifiersChecker: ModifiersChecker,
|
||||
private val annotationChecker: AnnotationChecker,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
fun withTrace(trace: BindingTrace) =
|
||||
DeclarationsChecker(descriptorResolver, originalModifiersChecker, annotationChecker, identifierChecker, trace, languageFeatureSettings)
|
||||
DeclarationsChecker(descriptorResolver, originalModifiersChecker, annotationChecker, identifierChecker, trace, languageVersionSettings)
|
||||
}
|
||||
|
||||
class DeclarationsChecker(
|
||||
@@ -85,7 +85,7 @@ class DeclarationsChecker(
|
||||
private val annotationChecker: AnnotationChecker,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val trace: BindingTrace,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
|
||||
private val modifiersChecker = modifiersChecker.withTrace(trace)
|
||||
@@ -249,7 +249,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
}
|
||||
annotationChecker.check(packageDirective, trace, null)
|
||||
ModifierCheckerCore.check(packageDirective, trace, descriptor = null, languageFeatureSettings = languageFeatureSettings)
|
||||
ModifierCheckerCore.check(packageDirective, trace, descriptor = null, languageVersionSettings = languageVersionSettings)
|
||||
}
|
||||
|
||||
private fun checkTypesInClassHeader(classOrObject: KtClassOrObject) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationSplitter;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
|
||||
@@ -77,7 +77,7 @@ public class DescriptorResolver {
|
||||
private final VariableTypeResolver variableTypeResolver;
|
||||
private final ExpressionTypingServices expressionTypingServices;
|
||||
private final OverloadChecker overloadChecker;
|
||||
private final LanguageFeatureSettings languageFeatureSettings;
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
private final FunctionsTypingVisitor functionsTypingVisitor;
|
||||
|
||||
public DescriptorResolver(
|
||||
@@ -89,7 +89,7 @@ public class DescriptorResolver {
|
||||
@NotNull VariableTypeResolver variableTypeResolver,
|
||||
@NotNull ExpressionTypingServices expressionTypingServices,
|
||||
@NotNull OverloadChecker overloadChecker,
|
||||
@NotNull LanguageFeatureSettings languageFeatureSettings,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull FunctionsTypingVisitor functionsTypingVisitor
|
||||
) {
|
||||
this.annotationResolver = annotationResolver;
|
||||
@@ -100,7 +100,7 @@ public class DescriptorResolver {
|
||||
this.variableTypeResolver = variableTypeResolver;
|
||||
this.expressionTypingServices = expressionTypingServices;
|
||||
this.overloadChecker = overloadChecker;
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
this.functionsTypingVisitor = functionsTypingVisitor;
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ public class DescriptorResolver {
|
||||
ErrorUtils.createErrorType(name.asString()),
|
||||
ErrorUtils.createErrorType(name.asString()));
|
||||
}
|
||||
else if (!languageFeatureSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||
else if (!languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||
typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace);
|
||||
PsiElement typeAliasKeyword = typeAlias.getTypeAliasKeyword();
|
||||
trace.report(UNSUPPORTED_TYPEALIAS.on(typeAliasKeyword != null ? typeAliasKeyword : typeAlias));
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.common.collect.HashMultimap
|
||||
import com.google.common.collect.Multimap
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||
@@ -47,7 +47,7 @@ class LazyTopDownAnalyzer(
|
||||
private val declarationScopeProvider: DeclarationScopeProvider,
|
||||
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
fun analyzeDeclarations(topDownAnalysisMode: TopDownAnalysisMode, declarations: Collection<PsiElement>, outerDataFlowInfo: DataFlowInfo): TopDownAnalysisContext {
|
||||
|
||||
@@ -214,7 +214,7 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
private fun createTypeAliasDescriptors(c: TopDownAnalysisContext, topLevelFqNames: Multimap<FqName, KtElement>, typeAliases: List<KtTypeAlias>) {
|
||||
if (!languageFeatureSettings.supportsFeature(LanguageFeature.TypeAliases)) return
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)) return
|
||||
|
||||
for (typeAlias in typeAliases) {
|
||||
val descriptor = lazyDeclarationResolver.resolveToDescriptor(typeAlias) as TypeAliasDescriptor
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
@@ -43,7 +43,7 @@ class LocalVariableResolver(
|
||||
private val annotationResolver: AnnotationResolver,
|
||||
private val variableTypeResolver: VariableTypeResolver,
|
||||
private val delegatedPropertyResolver: DelegatedPropertyResolver,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
|
||||
fun process(
|
||||
@@ -72,7 +72,7 @@ class LocalVariableResolver(
|
||||
|
||||
val delegateExpression = property.delegateExpression
|
||||
if (delegateExpression != null) {
|
||||
if (!languageFeatureSettings.supportsFeature(LanguageFeature.LocalDelegatedProperties)) {
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.LocalDelegatedProperties)) {
|
||||
context.trace.report(LOCAL_VARIABLE_WITH_DELEGATE.on(property.delegate!!))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
@@ -161,11 +161,11 @@ public class ModifiersChecker {
|
||||
@NotNull
|
||||
private final BindingTrace trace;
|
||||
@NotNull
|
||||
private final LanguageFeatureSettings languageFeatureSettings;
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
|
||||
private ModifiersCheckingProcedure(@NotNull BindingTrace trace, LanguageFeatureSettings languageFeatureSettings) {
|
||||
private ModifiersCheckingProcedure(@NotNull BindingTrace trace, LanguageVersionSettings languageVersionSettings) {
|
||||
this.trace = trace;
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
}
|
||||
|
||||
public void checkParameterHasNoValOrVar(
|
||||
@@ -188,7 +188,7 @@ public class ModifiersChecker {
|
||||
AnnotationUseSiteTargetChecker.INSTANCE.check(modifierListOwner, descriptor, trace);
|
||||
runDeclarationCheckers(modifierListOwner, descriptor);
|
||||
annotationChecker.check(modifierListOwner, trace, descriptor);
|
||||
ModifierCheckerCore.INSTANCE.check(modifierListOwner, trace, descriptor, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(modifierListOwner, trace, descriptor, languageVersionSettings);
|
||||
}
|
||||
|
||||
public void checkModifiersForLocalDeclaration(
|
||||
@@ -200,10 +200,10 @@ public class ModifiersChecker {
|
||||
|
||||
public void checkModifiersForDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration) {
|
||||
annotationChecker.check(multiDeclaration, trace, null);
|
||||
ModifierCheckerCore.INSTANCE.check(multiDeclaration, trace, null, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(multiDeclaration, trace, null, languageVersionSettings);
|
||||
for (KtDestructuringDeclarationEntry multiEntry: multiDeclaration.getEntries()) {
|
||||
annotationChecker.check(multiEntry, trace, null);
|
||||
ModifierCheckerCore.INSTANCE.check(multiEntry, trace, null, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(multiEntry, trace, null, languageVersionSettings);
|
||||
UnderscoreChecker.INSTANCE.checkNamed(multiEntry, trace);
|
||||
}
|
||||
}
|
||||
@@ -239,16 +239,16 @@ public class ModifiersChecker {
|
||||
@NotNull DeclarationDescriptor descriptor
|
||||
) {
|
||||
for (DeclarationChecker checker : declarationCheckers) {
|
||||
checker.check(declaration, descriptor, trace, trace.getBindingContext(), languageFeatureSettings);
|
||||
checker.check(declaration, descriptor, trace, trace.getBindingContext(), languageVersionSettings);
|
||||
}
|
||||
OperatorModifierChecker.INSTANCE.check(declaration, descriptor, trace, languageFeatureSettings);
|
||||
OperatorModifierChecker.INSTANCE.check(declaration, descriptor, trace, languageVersionSettings);
|
||||
}
|
||||
|
||||
public void checkTypeParametersModifiers(@NotNull KtModifierListOwner modifierListOwner) {
|
||||
if (!(modifierListOwner instanceof KtTypeParameterListOwner)) return;
|
||||
List<KtTypeParameter> typeParameters = ((KtTypeParameterListOwner) modifierListOwner).getTypeParameters();
|
||||
for (KtTypeParameter typeParameter : typeParameters) {
|
||||
ModifierCheckerCore.INSTANCE.check(typeParameter, trace, null, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(typeParameter, trace, null, languageVersionSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,20 +260,20 @@ public class ModifiersChecker {
|
||||
private final Iterable<DeclarationChecker> declarationCheckers;
|
||||
|
||||
@NotNull
|
||||
private final LanguageFeatureSettings languageFeatureSettings;
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
|
||||
public ModifiersChecker(
|
||||
@NotNull AnnotationChecker annotationChecker,
|
||||
@NotNull Iterable<DeclarationChecker> declarationCheckers,
|
||||
@NotNull LanguageFeatureSettings languageFeatureSettings
|
||||
@NotNull LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
this.annotationChecker = annotationChecker;
|
||||
this.declarationCheckers = declarationCheckers;
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModifiersCheckingProcedure withTrace(@NotNull BindingTrace trace) {
|
||||
return new ModifiersCheckingProcedure(trace, languageFeatureSettings);
|
||||
return new ModifiersCheckingProcedure(trace, languageVersionSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -257,14 +257,14 @@ object ModifierCheckerCore {
|
||||
private fun checkLanguageLevelSupport(
|
||||
trace: BindingTrace,
|
||||
node: ASTNode,
|
||||
languageFeatureSettings: LanguageFeatureSettings,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
actualTargets: List<KotlinTarget>
|
||||
): Boolean {
|
||||
val modifier = node.elementType as KtModifierKeywordToken
|
||||
|
||||
val dependency = featureDependencies[modifier] ?: return true
|
||||
|
||||
if (!languageFeatureSettings.supportsFeature(dependency)) {
|
||||
if (!languageVersionSettings.supportsFeature(dependency)) {
|
||||
val restrictedTargets = featureDependenciesTargets[dependency]
|
||||
if (restrictedTargets != null && actualTargets.intersect(restrictedTargets).isEmpty()) {
|
||||
return true
|
||||
@@ -304,7 +304,7 @@ object ModifierCheckerCore {
|
||||
trace: BindingTrace,
|
||||
parentDescriptor: DeclarationDescriptor?,
|
||||
actualTargets: List<KotlinTarget>,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
// It's a list of all nodes with error already reported
|
||||
// General strategy: report no more than one error but any number of warnings
|
||||
@@ -324,7 +324,7 @@ object ModifierCheckerCore {
|
||||
else if (!checkParent(trace, second, parentDescriptor)) {
|
||||
incorrectNodes += second
|
||||
}
|
||||
else if (!checkLanguageLevelSupport(trace, second, languageFeatureSettings, actualTargets)) {
|
||||
else if (!checkLanguageLevelSupport(trace, second, languageVersionSettings, actualTargets)) {
|
||||
incorrectNodes += second
|
||||
}
|
||||
}
|
||||
@@ -335,18 +335,18 @@ object ModifierCheckerCore {
|
||||
listOwner: KtModifierListOwner,
|
||||
trace: BindingTrace,
|
||||
descriptor: DeclarationDescriptor?,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
if (listOwner is KtDeclarationWithBody) {
|
||||
// JetFunction or JetPropertyAccessor
|
||||
for (parameter in listOwner.valueParameters) {
|
||||
if (!parameter.hasValOrVar()) {
|
||||
check(parameter, trace, null, languageFeatureSettings)
|
||||
check(parameter, trace, null, languageVersionSettings)
|
||||
}
|
||||
}
|
||||
}
|
||||
val actualTargets = AnnotationChecker.getDeclarationSiteActualTargetList(listOwner, descriptor as? ClassDescriptor, trace)
|
||||
val list = listOwner.modifierList ?: return
|
||||
checkModifierList(list, trace, descriptor?.containingDeclaration, actualTargets, languageFeatureSettings)
|
||||
checkModifierList(list, trace, descriptor?.containingDeclaration, actualTargets, languageVersionSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
@@ -49,7 +49,7 @@ object OperatorModifierChecker {
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
val functionDescriptor = descriptor as? FunctionDescriptor ?: return
|
||||
if (!functionDescriptor.isOperator) return
|
||||
@@ -58,7 +58,7 @@ object OperatorModifierChecker {
|
||||
val checkResult = OperatorChecks.check(functionDescriptor)
|
||||
if (checkResult.isSuccess) {
|
||||
if (functionDescriptor.name in COROUTINE_OPERATOR_NAMES
|
||||
&& !languageFeatureSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
||||
&& !languageVersionSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
||||
diagnosticHolder.report(Errors.UNSUPPORTED_FEATURE.on(modifier, LanguageFeature.Coroutines))
|
||||
}
|
||||
return
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve
|
||||
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.context.TypeLazinessToken
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -60,7 +60,7 @@ class TypeResolver(
|
||||
private val dynamicTypesSettings: DynamicTypesSettings,
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
|
||||
open class TypeTransformerForTests {
|
||||
@@ -454,7 +454,7 @@ class TypeResolver(
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
return createErrorTypeForTypeConstructor(c, projectionFromAllQualifierParts, typeConstructor)
|
||||
}
|
||||
if (!languageFeatureSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||
c.trace.report(UNSUPPORTED_TYPEALIAS.on(type))
|
||||
return createErrorTypeForTypeConstructor(c, projectionFromAllQualifierParts, typeConstructor)
|
||||
}
|
||||
@@ -703,7 +703,7 @@ class TypeResolver(
|
||||
): List<TypeProjection> {
|
||||
return argumentElements.mapIndexed { i, argumentElement ->
|
||||
val projectionKind = argumentElement.projectionKind
|
||||
ModifierCheckerCore.check(argumentElement, c.trace, null, languageFeatureSettings)
|
||||
ModifierCheckerCore.check(argumentElement, c.trace, null, languageVersionSettings)
|
||||
if (projectionKind == KtProjectionKind.STAR) {
|
||||
val parameters = constructor.parameters
|
||||
if (parameters.size > i) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.coroutines.controllerTypeIfCoroutine
|
||||
import org.jetbrains.kotlin.coroutines.resolveCoroutineHandleResultCallIfNeeded
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
@@ -63,7 +63,7 @@ class CallCompleter(
|
||||
private val callCheckers: Iterable<CallChecker>,
|
||||
private val builtIns: KotlinBuiltIns,
|
||||
private val fakeCallResolver: FakeCallResolver,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
fun <D : CallableDescriptor> completeCall(
|
||||
context: BasicCallResolutionContext,
|
||||
@@ -94,7 +94,7 @@ class CallCompleter(
|
||||
if (calleeExpression != null && !calleeExpression.isFakeElement) calleeExpression
|
||||
else resolvedCall.call.callElement
|
||||
|
||||
val callCheckerContext = CallCheckerContext(context, languageFeatureSettings)
|
||||
val callCheckerContext = CallCheckerContext(context, languageVersionSettings)
|
||||
for (callChecker in callCheckers) {
|
||||
callChecker.check(resolvedCall, reportOn, callCheckerContext)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
@@ -72,16 +72,16 @@ public class CallResolver {
|
||||
private CallCompleter callCompleter;
|
||||
private NewResolutionOldInference newCallResolver;
|
||||
private final KotlinBuiltIns builtIns;
|
||||
private final LanguageFeatureSettings languageFeatureSettings;
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
|
||||
private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", ExpressionTypingVisitorDispatcher.typeInfoPerfCounter);
|
||||
|
||||
public CallResolver(
|
||||
@NotNull KotlinBuiltIns builtIns,
|
||||
@NotNull LanguageFeatureSettings languageFeatureSettings
|
||||
@NotNull LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
this.builtIns = builtIns;
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
}
|
||||
|
||||
// component dependency cycle
|
||||
@@ -589,7 +589,7 @@ public class CallResolver {
|
||||
for (KtTypeProjection projection : typeArguments) {
|
||||
if (projection.getProjectionKind() != KtProjectionKind.NONE) {
|
||||
context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection));
|
||||
ModifierCheckerCore.INSTANCE.check(projection, context.trace, null, languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(projection, context.trace, null, languageVersionSettings);
|
||||
}
|
||||
KotlinType type = argumentTypeResolver.resolveTypeRefWithDefault(
|
||||
projection.getTypeReference(), context.scope, context.trace,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
@@ -37,7 +37,7 @@ interface CallChecker {
|
||||
class CallCheckerContext(
|
||||
val resolutionContext: ResolutionContext<*>,
|
||||
val trace: BindingTrace,
|
||||
val languageFeatureSettings: LanguageFeatureSettings
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
val scope: LexicalScope
|
||||
get() = resolutionContext.scope
|
||||
@@ -48,7 +48,7 @@ class CallCheckerContext(
|
||||
val isAnnotationContext: Boolean
|
||||
get() = resolutionContext.isAnnotationContext
|
||||
|
||||
constructor(c: ResolutionContext<*>, languageFeatureSettings: LanguageFeatureSettings) : this(c, c.trace, languageFeatureSettings)
|
||||
constructor(c: ResolutionContext<*>, languageVersionSettings: LanguageVersionSettings) : this(c, c.trace, languageVersionSettings)
|
||||
}
|
||||
|
||||
// Use this utility to avoid premature computation of deferred return type of a resolved callable descriptor.
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ object BuilderFunctionsCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor as? FunctionDescriptor ?: return
|
||||
if (descriptor.valueParameters.any { it.isCoroutine } &&
|
||||
!context.languageFeatureSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
||||
!context.languageVersionSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
||||
context.trace.report(Errors.UNSUPPORTED_FEATURE.on(reportOn, LanguageFeature.Coroutines))
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -605,7 +605,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
trace.record(RESOLVED_CALL, call, resolvedCall);
|
||||
trace.record(CALL, expression, call);
|
||||
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, components.languageFeatureSettings);
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, components.languageVersionSettings);
|
||||
for (CallChecker checker : components.callCheckers) {
|
||||
checker.check(resolvedCall, expression, callCheckerContext);
|
||||
}
|
||||
@@ -909,7 +909,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (resolvedCall != null) {
|
||||
// Call must be validated with the actual, not temporary trace in order to report operator diagnostic
|
||||
// Only unary assignment expressions (++, --) and +=/... must be checked, normal assignments have the proper trace
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, trace, components.languageFeatureSettings);
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, trace, components.languageVersionSettings);
|
||||
for (CallChecker checker : components.callCheckers) {
|
||||
checker.check(resolvedCall, expression, callCheckerContext);
|
||||
}
|
||||
@@ -975,7 +975,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
);
|
||||
resolvedCall.markCallAsCompleted();
|
||||
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, components.languageFeatureSettings);
|
||||
CallCheckerContext callCheckerContext = new CallCheckerContext(context, components.languageVersionSettings);
|
||||
for (CallChecker checker : components.callCheckers) {
|
||||
checker.check(resolvedCall, expression, callCheckerContext);
|
||||
}
|
||||
|
||||
+1
-3
@@ -32,8 +32,6 @@ import org.jetbrains.kotlin.resolve.ModifiersChecker;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
@@ -485,7 +483,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
components.identifierChecker.checkDeclaration(catchParameter, context.trace);
|
||||
ModifiersChecker.ModifiersCheckingProcedure modifiersChecking = components.modifiersChecker.withTrace(context.trace);
|
||||
modifiersChecking.checkParameterHasNoValOrVar(catchParameter, VAL_OR_VAR_ON_CATCH_PARAMETER);
|
||||
ModifierCheckerCore.INSTANCE.check(catchParameter, context.trace, null, components.languageFeatureSettings);
|
||||
ModifierCheckerCore.INSTANCE.check(catchParameter, context.trace, null, components.languageVersionSettings);
|
||||
|
||||
VariableDescriptor variableDescriptor = components.descriptorResolver.resolveLocalVariableDescriptor(
|
||||
context.scope, catchParameter, context.trace);
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.types.expressions
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.ReflectionTypes
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
@@ -68,7 +68,7 @@ class DoubleColonExpressionResolver(
|
||||
val dataFlowAnalyzer: DataFlowAnalyzer,
|
||||
val reflectionTypes: ReflectionTypes,
|
||||
val typeResolver: TypeResolver,
|
||||
val languageFeatureSettings: LanguageFeatureSettings
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
private lateinit var expressionTypingServices: ExpressionTypingServices
|
||||
|
||||
@@ -151,7 +151,7 @@ class DoubleColonExpressionResolver(
|
||||
|
||||
private fun shouldTryResolveLHSAsExpression(expression: KtDoubleColonExpression): Boolean {
|
||||
// TODO: improve diagnostic when bound callable references are disabled
|
||||
if (!languageFeatureSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return false
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return false
|
||||
|
||||
val lhs = expression.receiverExpression ?: return false
|
||||
return lhs.canBeConsideredProperExpression() && !expression.hasQuestionMarks /* TODO: test this */
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.types.expressions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.context.GlobalContext;
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker;
|
||||
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap;
|
||||
@@ -57,7 +57,7 @@ public class ExpressionTypingComponents {
|
||||
/*package*/ LocalVariableResolver localVariableResolver;
|
||||
/*package*/ LookupTracker lookupTracker;
|
||||
/*package*/ OverloadChecker overloadChecker;
|
||||
/*package*/ LanguageFeatureSettings languageFeatureSettings;
|
||||
/*package*/ LanguageVersionSettings languageVersionSettings;
|
||||
|
||||
@Inject
|
||||
public void setGlobalContext(@NotNull GlobalContext globalContext) {
|
||||
@@ -190,7 +190,7 @@ public class ExpressionTypingComponents {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setLanguageFeatureSettings(@NotNull LanguageFeatureSettings languageFeatureSettings) {
|
||||
this.languageFeatureSettings = languageFeatureSettings;
|
||||
public void setLanguageVersionSettings(@NotNull LanguageVersionSettings languageVersionSettings) {
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.types.expressions
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.context.GlobalContext
|
||||
import org.jetbrains.kotlin.context.withModule
|
||||
@@ -60,7 +60,7 @@ class LocalClassifierAnalyzer(
|
||||
private val platform: TargetPlatform,
|
||||
private val lookupTracker: LookupTracker,
|
||||
private val supertypeLoopChecker: SupertypeLoopChecker,
|
||||
private val languageFeatureSettings: LanguageFeatureSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
fun processClassOrObject(
|
||||
scope: LexicalWritableScope?,
|
||||
@@ -75,7 +75,7 @@ class LocalClassifierAnalyzer(
|
||||
context.trace,
|
||||
platform,
|
||||
lookupTracker,
|
||||
languageFeatureSettings,
|
||||
languageVersionSettings,
|
||||
LocalClassDescriptorHolder(
|
||||
scope,
|
||||
classOrObject,
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider;
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.context.ContextKt;
|
||||
import org.jetbrains.kotlin.context.GlobalContext;
|
||||
import org.jetbrains.kotlin.context.ModuleContext;
|
||||
@@ -135,9 +135,9 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
|
||||
moduleBindings.put(testModule, moduleTrace.getBindingContext());
|
||||
|
||||
LanguageFeatureSettings languageFeatureSettings = loadCustomLanguageFeatureSettings(testFilesInModule);
|
||||
LanguageVersionSettings languageVersionSettings = loadCustomLanguageVersionSettings(testFilesInModule);
|
||||
ModuleContext moduleContext = ContextKt.withModule(ContextKt.withProject(context, getProject()), module);
|
||||
analyzeModuleContents(moduleContext, jetFiles, moduleTrace, languageFeatureSettings);
|
||||
analyzeModuleContents(moduleContext, jetFiles, moduleTrace, languageVersionSettings);
|
||||
|
||||
checkAllResolvedCallsAreCompleted(jetFiles, moduleTrace.getBindingContext());
|
||||
}
|
||||
@@ -197,17 +197,17 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private LanguageFeatureSettings loadCustomLanguageFeatureSettings(List<? extends TestFile> module) {
|
||||
LanguageFeatureSettings result = null;
|
||||
private LanguageVersionSettings loadCustomLanguageVersionSettings(List<? extends TestFile> module) {
|
||||
LanguageVersionSettings result = null;
|
||||
for (TestFile file : module) {
|
||||
if (file.customLanguageFeatureSettings != null) {
|
||||
if (file.customLanguageVersionSettings != null) {
|
||||
if (result != null) {
|
||||
Assert.fail(
|
||||
"More than one file in the module has " + BaseDiagnosticsTest.LANGUAGE_DIRECTIVE + " directive specified. " +
|
||||
"This is not supported. Please move all directives into one file"
|
||||
);
|
||||
}
|
||||
result = file.customLanguageFeatureSettings;
|
||||
result = file.customLanguageVersionSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,12 +264,12 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
@NotNull ModuleContext moduleContext,
|
||||
@NotNull List<KtFile> files,
|
||||
@NotNull BindingTrace moduleTrace,
|
||||
@Nullable LanguageFeatureSettings languageFeatureSettings
|
||||
@Nullable LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
CompilerConfiguration configuration;
|
||||
if (languageFeatureSettings != null) {
|
||||
if (languageVersionSettings != null) {
|
||||
configuration = getEnvironment().getConfiguration().copy();
|
||||
configuration.put(CommonConfigurationKeys.LANGUAGE_FEATURE_SETTINGS, languageFeatureSettings);
|
||||
configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, languageVersionSettings);
|
||||
}
|
||||
else {
|
||||
configuration = getEnvironment().getConfiguration();
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.context.ModuleContext;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS;
|
||||
@@ -72,10 +72,10 @@ public abstract class AbstractDiagnosticsTestWithJsStdLib extends AbstractDiagno
|
||||
@NotNull ModuleContext moduleContext,
|
||||
@NotNull List<KtFile> ktFiles,
|
||||
@NotNull BindingTrace moduleTrace,
|
||||
@Nullable LanguageFeatureSettings languageFeatureSettings
|
||||
@Nullable LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
// TODO: support LANGUAGE directive in JS diagnostic tests
|
||||
assert languageFeatureSettings == null
|
||||
assert languageVersionSettings == null
|
||||
: BaseDiagnosticsTest.LANGUAGE_DIRECTIVE + " directive is not supported in JS diagnostic tests";
|
||||
return TopDownAnalyzerFacadeForJS.analyzeFilesWithGivenTrace(ktFiles, moduleTrace, moduleContext, config);
|
||||
}
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.hasError
|
||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
|
||||
@@ -30,9 +30,9 @@ abstract class AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation : Abstra
|
||||
moduleContext: ModuleContext,
|
||||
ktFiles: MutableList<KtFile>,
|
||||
moduleTrace: BindingTrace,
|
||||
languageFeatureSettings: LanguageFeatureSettings?
|
||||
languageVersionSettings: LanguageVersionSettings?
|
||||
): JsAnalysisResult {
|
||||
val analysisResult = super.analyzeModuleContents(moduleContext, ktFiles, moduleTrace, languageFeatureSettings)
|
||||
val analysisResult = super.analyzeModuleContents(moduleContext, ktFiles, moduleTrace, languageVersionSettings)
|
||||
val diagnostics = analysisResult.bindingTrace.bindingContext.diagnostics
|
||||
|
||||
if (!hasError(diagnostics)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.asJava.DuplicateJvmSignatureUtilKt;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.*;
|
||||
@@ -155,7 +155,7 @@ public abstract class BaseDiagnosticsTest
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LanguageFeatureSettings parseLanguageFeatureSettingsDirective(Map<String, String> directiveMap) {
|
||||
private static LanguageVersionSettings parseLanguageDirective(Map<String, String> directiveMap) {
|
||||
String directives = directiveMap.get(LANGUAGE_DIRECTIVE);
|
||||
if (directives == null) return null;
|
||||
|
||||
@@ -187,7 +187,7 @@ public abstract class BaseDiagnosticsTest
|
||||
}
|
||||
while (matcher.find());
|
||||
|
||||
return new LanguageFeatureSettings() {
|
||||
return new LanguageVersionSettings() {
|
||||
@Override
|
||||
public boolean supportsFeature(@NotNull LanguageFeature feature) {
|
||||
Boolean enabled = values.get(feature);
|
||||
@@ -296,7 +296,7 @@ public abstract class BaseDiagnosticsTest
|
||||
private final String clearText;
|
||||
private final KtFile jetFile;
|
||||
private final Condition<Diagnostic> whatDiagnosticsToConsider;
|
||||
public final LanguageFeatureSettings customLanguageFeatureSettings;
|
||||
public final LanguageVersionSettings customLanguageVersionSettings;
|
||||
private final boolean declareCheckType;
|
||||
private final boolean declareFlexibleType;
|
||||
public final boolean checkLazyLog;
|
||||
@@ -311,7 +311,7 @@ public abstract class BaseDiagnosticsTest
|
||||
) {
|
||||
this.module = module;
|
||||
this.whatDiagnosticsToConsider = parseDiagnosticFilterDirective(directives);
|
||||
this.customLanguageFeatureSettings = parseLanguageFeatureSettingsDirective(directives);
|
||||
this.customLanguageVersionSettings = parseLanguageDirective(directives);
|
||||
this.checkLazyLog = directives.containsKey(CHECK_LAZY_LOG_DIRECTIVE) || CHECK_LAZY_LOG_DEFAULT;
|
||||
this.declareCheckType = directives.containsKey(CHECK_TYPE_DIRECTIVE);
|
||||
this.declareFlexibleType = directives.containsKey(EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.frontend.js.di
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeatureSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.createContainer
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
@@ -36,7 +36,7 @@ fun createTopDownAnalyzerForJs(
|
||||
moduleContext: ModuleContext,
|
||||
bindingTrace: BindingTrace,
|
||||
declarationProviderFactory: DeclarationProviderFactory,
|
||||
languageFeatureSettings: LanguageFeatureSettings
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): LazyTopDownAnalyzerForTopLevel {
|
||||
val storageComponentContainer = createContainer("TopDownAnalyzerForJs") {
|
||||
configureModule(moduleContext, JsPlatform, bindingTrace)
|
||||
@@ -47,7 +47,7 @@ fun createTopDownAnalyzerForJs(
|
||||
CompilerEnvironment.configure(this)
|
||||
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(languageFeatureSettings)
|
||||
useInstance(languageVersionSettings)
|
||||
useImpl<ResolveSession>()
|
||||
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class TopDownAnalyzerFacadeForJS {
|
||||
LazyTopDownAnalyzerForTopLevel analyzerForJs = InjectionKt.createTopDownAnalyzerForJs(
|
||||
moduleContext, trace,
|
||||
new FileBasedDeclarationProviderFactory(moduleContext.getStorageManager(), allFiles),
|
||||
config.getConfiguration().get(CommonConfigurationKeys.LANGUAGE_FEATURE_SETTINGS, LanguageVersionSettingsImpl.DEFAULT)
|
||||
config.getConfiguration().get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT)
|
||||
);
|
||||
analyzerForJs.analyzeFiles(TopDownAnalysisMode.TopLevelDeclarations, files, Collections.<PackageFragmentProvider>emptyList());
|
||||
return JsAnalysisResult.success(trace, moduleContext.getModule());
|
||||
|
||||
Reference in New Issue
Block a user