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