Drop TypeLazinessToken and LazyResolveToken
This commit is contained in:
@@ -19,19 +19,18 @@ 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.builtins.JvmBuiltInsPackageFragmentProvider
|
import org.jetbrains.kotlin.builtins.JvmBuiltInsPackageFragmentProvider
|
||||||
import org.jetbrains.kotlin.javac.components.JavacBasedClassFinder
|
|
||||||
import org.jetbrains.kotlin.javac.components.StubJavaResolverCache
|
|
||||||
import org.jetbrains.kotlin.javac.components.JavacBasedSourceElementFactory
|
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
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.ModuleContext
|
import org.jetbrains.kotlin.context.ModuleContext
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||||
import org.jetbrains.kotlin.frontend.di.configureModule
|
import org.jetbrains.kotlin.frontend.di.configureModule
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
|
import org.jetbrains.kotlin.javac.components.JavacBasedClassFinder
|
||||||
|
import org.jetbrains.kotlin.javac.components.JavacBasedSourceElementFactory
|
||||||
|
import org.jetbrains.kotlin.javac.components.StubJavaResolverCache
|
||||||
import org.jetbrains.kotlin.load.java.InternalFlexibleTypeTransformer
|
import org.jetbrains.kotlin.load.java.InternalFlexibleTypeTransformer
|
||||||
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
||||||
import org.jetbrains.kotlin.load.java.components.*
|
import org.jetbrains.kotlin.load.java.components.*
|
||||||
@@ -98,7 +97,6 @@ fun createContainerForLazyResolveWithJava(
|
|||||||
jvmTarget: JvmTarget,
|
jvmTarget: JvmTarget,
|
||||||
languageVersionSettings: LanguageVersionSettings,
|
languageVersionSettings: LanguageVersionSettings,
|
||||||
useBuiltInsProvider: Boolean,
|
useBuiltInsProvider: Boolean,
|
||||||
useLazyResolve: Boolean,
|
|
||||||
useJavac: Boolean = false
|
useJavac: Boolean = false
|
||||||
): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatform) {
|
): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatform) {
|
||||||
configureModule(moduleContext, JvmPlatform, jvmTarget, bindingTrace)
|
configureModule(moduleContext, JvmPlatform, jvmTarget, bindingTrace)
|
||||||
@@ -116,10 +114,6 @@ fun createContainerForLazyResolveWithJava(
|
|||||||
}
|
}
|
||||||
|
|
||||||
targetEnvironment.configure(this)
|
targetEnvironment.configure(this)
|
||||||
|
|
||||||
if (useLazyResolve) {
|
|
||||||
useImpl<LazyResolveToken>()
|
|
||||||
}
|
|
||||||
}.apply {
|
}.apply {
|
||||||
if (useJavac)
|
if (useJavac)
|
||||||
get<JavacBasedClassFinder>().initialize(bindingTrace, get<KotlinCodeAnalyzer>())
|
get<JavacBasedClassFinder>().initialize(bindingTrace, get<KotlinCodeAnalyzer>())
|
||||||
@@ -142,7 +136,7 @@ fun createContainerForTopDownAnalyzerForJvm(
|
|||||||
): ComponentProvider = createContainerForLazyResolveWithJava(
|
): ComponentProvider = createContainerForLazyResolveWithJava(
|
||||||
moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope, moduleClassResolver,
|
moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope, moduleClassResolver,
|
||||||
CompilerEnvironment, lookupTracker, packagePartProvider, jvmTarget, languageVersionSettings,
|
CompilerEnvironment, lookupTracker, packagePartProvider, jvmTarget, languageVersionSettings,
|
||||||
useBuiltInsProvider = true, useLazyResolve = false, useJavac = useJavac
|
useBuiltInsProvider = true, useJavac = useJavac
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ object JvmAnalyzerFacade : AnalyzerFacade<JvmPlatformParameters>() {
|
|||||||
packagePartProvider,
|
packagePartProvider,
|
||||||
jvmTarget,
|
jvmTarget,
|
||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
useBuiltInsProvider = false, // TODO: load built-ins from module dependencies in IDE
|
useBuiltInsProvider = false // TODO: load built-ins from module dependencies in IDE
|
||||||
useLazyResolve = true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
StorageComponentContainerContributor.getInstances(project).forEach { it.onContainerComposed(container, moduleInfo) }
|
StorageComponentContainerContributor.getInstances(project).forEach { it.onContainerComposed(container, moduleInfo) }
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.container.StorageComponentContainer
|
|||||||
import org.jetbrains.kotlin.container.get
|
import org.jetbrains.kotlin.container.get
|
||||||
import org.jetbrains.kotlin.container.useImpl
|
import org.jetbrains.kotlin.container.useImpl
|
||||||
import org.jetbrains.kotlin.container.useInstance
|
import org.jetbrains.kotlin.container.useInstance
|
||||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
|
||||||
import org.jetbrains.kotlin.context.ModuleContext
|
import org.jetbrains.kotlin.context.ModuleContext
|
||||||
import org.jetbrains.kotlin.context.ProjectContext
|
import org.jetbrains.kotlin.context.ProjectContext
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
@@ -144,7 +143,6 @@ object DefaultAnalyzerFacade : AnalyzerFacade<PlatformAnalysisParameters>() {
|
|||||||
useInstance(metadataFinderFactory.create(moduleContentScope))
|
useInstance(metadataFinderFactory.create(moduleContentScope))
|
||||||
|
|
||||||
targetEnvironment.configure(this)
|
targetEnvironment.configure(this)
|
||||||
useImpl<LazyResolveToken>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val targetPlatform: TargetPlatform
|
override val targetPlatform: TargetPlatform
|
||||||
|
|||||||
@@ -104,15 +104,3 @@ fun ContextForNewModule(
|
|||||||
val module = ModuleDescriptorImpl(moduleName, projectContext.storageManager, builtIns, multiTargetPlatform)
|
val module = ModuleDescriptorImpl(moduleName, projectContext.storageManager, builtIns, multiTargetPlatform)
|
||||||
return MutableModuleContextImpl(module, projectContext)
|
return MutableModuleContextImpl(module, projectContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Deprecated("Used temporarily while we are in transition from to lazy resolve")
|
|
||||||
open class TypeLazinessToken {
|
|
||||||
@Deprecated("Used temporarily while we are in transition from to lazy resolve")
|
|
||||||
open fun isLazy(): Boolean = false
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated("Used temporarily while we are in transition from to lazy resolve") class LazyResolveToken : TypeLazinessToken() {
|
|
||||||
@Deprecated("Used temporarily while we are in transition from to lazy resolve")
|
|
||||||
override fun isLazy() = true
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.container.StorageComponentContainer
|
|||||||
import org.jetbrains.kotlin.container.get
|
import org.jetbrains.kotlin.container.get
|
||||||
import org.jetbrains.kotlin.container.useImpl
|
import org.jetbrains.kotlin.container.useImpl
|
||||||
import org.jetbrains.kotlin.container.useInstance
|
import org.jetbrains.kotlin.container.useInstance
|
||||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
|
||||||
import org.jetbrains.kotlin.context.ModuleContext
|
import org.jetbrains.kotlin.context.ModuleContext
|
||||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
@@ -161,7 +160,6 @@ fun createContainerForLazyResolve(
|
|||||||
useImpl<CompilerDeserializationConfiguration>()
|
useImpl<CompilerDeserializationConfiguration>()
|
||||||
targetEnvironment.configure(this)
|
targetEnvironment.configure(this)
|
||||||
|
|
||||||
useImpl<LazyResolveToken>()
|
|
||||||
useImpl<ResolveSession>()
|
useImpl<ResolveSession>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,24 +24,18 @@ public class TypeResolutionContext {
|
|||||||
public final BindingTrace trace;
|
public final BindingTrace trace;
|
||||||
public final boolean checkBounds;
|
public final boolean checkBounds;
|
||||||
public final boolean allowBareTypes;
|
public final boolean allowBareTypes;
|
||||||
public final boolean forceResolveLazyTypes;
|
|
||||||
public final boolean isDebuggerContext;
|
public final boolean isDebuggerContext;
|
||||||
public final boolean abbreviated;
|
public final boolean abbreviated;
|
||||||
|
|
||||||
public TypeResolutionContext(@NotNull LexicalScope scope, @NotNull BindingTrace trace, boolean checkBounds, boolean allowBareTypes, boolean isDebuggerContext) {
|
public TypeResolutionContext(@NotNull LexicalScope scope, @NotNull BindingTrace trace, boolean checkBounds, boolean allowBareTypes, boolean isDebuggerContext) {
|
||||||
this(scope, trace, checkBounds, allowBareTypes, allowBareTypes, isDebuggerContext, false);
|
this(scope, trace, checkBounds, allowBareTypes, isDebuggerContext, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeResolutionContext(@NotNull LexicalScope scope, @NotNull BindingTrace trace, boolean checkBounds, boolean allowBareTypes, boolean isDebuggerContext, boolean abbreviated) {
|
public TypeResolutionContext(
|
||||||
this(scope, trace, checkBounds, allowBareTypes, allowBareTypes, isDebuggerContext, abbreviated);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TypeResolutionContext(
|
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
boolean checkBounds,
|
boolean checkBounds,
|
||||||
boolean allowBareTypes,
|
boolean allowBareTypes,
|
||||||
boolean forceResolveLazyTypes,
|
|
||||||
boolean isDebuggerContext,
|
boolean isDebuggerContext,
|
||||||
boolean abbreviated
|
boolean abbreviated
|
||||||
) {
|
) {
|
||||||
@@ -49,12 +43,12 @@ public class TypeResolutionContext {
|
|||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
this.checkBounds = checkBounds;
|
this.checkBounds = checkBounds;
|
||||||
this.allowBareTypes = allowBareTypes;
|
this.allowBareTypes = allowBareTypes;
|
||||||
this.forceResolveLazyTypes = forceResolveLazyTypes;
|
|
||||||
this.isDebuggerContext = isDebuggerContext;
|
this.isDebuggerContext = isDebuggerContext;
|
||||||
this.abbreviated = abbreviated;
|
this.abbreviated = abbreviated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public TypeResolutionContext noBareTypes() {
|
public TypeResolutionContext noBareTypes() {
|
||||||
return new TypeResolutionContext(scope, trace, checkBounds, false, forceResolveLazyTypes, isDebuggerContext, abbreviated);
|
return new TypeResolutionContext(scope, trace, checkBounds, false, isDebuggerContext, abbreviated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.intellij.util.SmartList
|
|||||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.context.TypeLazinessToken
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
@@ -62,11 +61,9 @@ class TypeResolver(
|
|||||||
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
||||||
private val moduleDescriptor: ModuleDescriptor,
|
private val moduleDescriptor: ModuleDescriptor,
|
||||||
private val typeTransformerForTests: TypeTransformerForTests,
|
private val typeTransformerForTests: TypeTransformerForTests,
|
||||||
private val lazinessToken: TypeLazinessToken,
|
|
||||||
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 wrappedTypeFactory: WrappedTypeFactory,
|
|
||||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
||||||
private val languageVersionSettings: LanguageVersionSettings
|
private val languageVersionSettings: LanguageVersionSettings
|
||||||
) {
|
) {
|
||||||
@@ -115,37 +112,16 @@ class TypeResolver(
|
|||||||
return type(debugType)
|
return type(debugType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.allowBareTypes && !c.forceResolveLazyTypes && lazinessToken.isLazy()) {
|
|
||||||
// Bare types can be allowed only inside expressions; lazy type resolution is only relevant for declarations
|
|
||||||
|
|
||||||
val lazyKotlinType = wrappedTypeFactory.createLazyWrappedType {
|
|
||||||
doResolvePossiblyBareType(c, typeReference).actualType
|
|
||||||
}
|
|
||||||
c.trace.record(resolvedTypeSlice, typeReference, lazyKotlinType)
|
|
||||||
return type(lazyKotlinType)
|
|
||||||
}
|
|
||||||
|
|
||||||
val type = doResolvePossiblyBareType(c, typeReference)
|
|
||||||
if (!type.isBare) {
|
|
||||||
c.trace.record(resolvedTypeSlice, typeReference, type.actualType)
|
|
||||||
}
|
|
||||||
return type
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun doResolvePossiblyBareType(c: TypeResolutionContext, typeReference: KtTypeReference): PossiblyBareType {
|
|
||||||
val typeElement = typeReference.typeElement
|
|
||||||
|
|
||||||
val annotations = resolveTypeAnnotations(c, typeReference)
|
val annotations = resolveTypeAnnotations(c, typeReference)
|
||||||
|
val type = resolveTypeElement(c, annotations, typeReference.modifierList, typeReference.typeElement)
|
||||||
val type = resolveTypeElement(c, annotations, typeReference.modifierList, typeElement)
|
|
||||||
c.trace.recordScope(c.scope, typeReference)
|
c.trace.recordScope(c.scope, typeReference)
|
||||||
|
|
||||||
if (!type.isBare) {
|
if (!type.isBare) {
|
||||||
for (argument in type.actualType.arguments) {
|
for (argument in type.actualType.arguments) {
|
||||||
forceResolveTypeContents(argument.type)
|
forceResolveTypeContents(argument.type)
|
||||||
}
|
}
|
||||||
|
c.trace.record(resolvedTypeSlice, typeReference, type.actualType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import org.jetbrains.kotlin.resolve.BindingTrace
|
|||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
|
||||||
open class WrappedTypeFactory(private val storageManager: StorageManager) {
|
open class WrappedTypeFactory(private val storageManager: StorageManager) {
|
||||||
open fun createLazyWrappedType(computation: () -> KotlinType): KotlinType = LazyWrappedType(storageManager, computation)
|
open fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType =
|
||||||
open fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType = DeferredType.create(storageManager, trace, computation)
|
DeferredType.create(storageManager, trace, computation)
|
||||||
open fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType = DeferredType.createRecursionIntolerant(storageManager, trace, computation)
|
|
||||||
}
|
open fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType =
|
||||||
|
DeferredType.createRecursionIntolerant(storageManager, trace, computation)
|
||||||
|
}
|
||||||
|
|||||||
-4
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.config.JvmTarget
|
|||||||
import org.jetbrains.kotlin.container.get
|
import org.jetbrains.kotlin.container.get
|
||||||
import org.jetbrains.kotlin.container.useImpl
|
import org.jetbrains.kotlin.container.useImpl
|
||||||
import org.jetbrains.kotlin.container.useInstance
|
import org.jetbrains.kotlin.container.useInstance
|
||||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
|
||||||
import org.jetbrains.kotlin.context.ModuleContext
|
import org.jetbrains.kotlin.context.ModuleContext
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
@@ -270,8 +269,6 @@ object IDELightClassContexts {
|
|||||||
useImpl<AdHocAnnotationResolver>()
|
useImpl<AdHocAnnotationResolver>()
|
||||||
|
|
||||||
useInstance(object : WrappedTypeFactory(sm) {
|
useInstance(object : WrappedTypeFactory(sm) {
|
||||||
override fun createLazyWrappedType(computation: () -> KotlinType): KotlinType = errorType()
|
|
||||||
|
|
||||||
override fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType()
|
override fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType()
|
||||||
|
|
||||||
override fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType()
|
override fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType()
|
||||||
@@ -280,7 +277,6 @@ object IDELightClassContexts {
|
|||||||
})
|
})
|
||||||
|
|
||||||
IdeaEnvironment.configure(this)
|
IdeaEnvironment.configure(this)
|
||||||
useImpl<LazyResolveToken>()
|
|
||||||
|
|
||||||
useImpl<ResolveSession>()
|
useImpl<ResolveSession>()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,6 +2,6 @@ package foo
|
|||||||
|
|
||||||
open class A<T>
|
open class A<T>
|
||||||
|
|
||||||
fun <T> f(<warning descr="[UNUSED_PARAMETER] Parameter 't' is never used">t</warning>: T<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed for type parameters"><<error descr="[DEBUG] Reference is not resolved to anything, but is not marked unresolved">T</error>></error>) {}
|
fun <T> f(<warning descr="[UNUSED_PARAMETER] Parameter 't' is never used">t</warning>: T<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed for type parameters"><T></error>) {}
|
||||||
|
|
||||||
fun <T> use(<warning descr="[UNUSED_PARAMETER] Parameter 'b' is never used">b</warning>: foo<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed here"><T></error>.A<T>) {}
|
fun <T> use(<warning descr="[UNUSED_PARAMETER] Parameter 'b' is never used">b</warning>: foo<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed here"><T></error>.A<T>) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user