diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt index c5064d19448..a4e38109af5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt @@ -19,19 +19,18 @@ package org.jetbrains.kotlin.frontend.java.di import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope 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.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.* -import org.jetbrains.kotlin.context.LazyResolveToken import org.jetbrains.kotlin.context.ModuleContext import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.PackagePartProvider import org.jetbrains.kotlin.frontend.di.configureModule 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.JavaClassFinderImpl import org.jetbrains.kotlin.load.java.components.* @@ -98,7 +97,6 @@ fun createContainerForLazyResolveWithJava( jvmTarget: JvmTarget, languageVersionSettings: LanguageVersionSettings, useBuiltInsProvider: Boolean, - useLazyResolve: Boolean, useJavac: Boolean = false ): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatform) { configureModule(moduleContext, JvmPlatform, jvmTarget, bindingTrace) @@ -116,10 +114,6 @@ fun createContainerForLazyResolveWithJava( } targetEnvironment.configure(this) - - if (useLazyResolve) { - useImpl() - } }.apply { if (useJavac) get().initialize(bindingTrace, get()) @@ -142,7 +136,7 @@ fun createContainerForTopDownAnalyzerForJvm( ): ComponentProvider = createContainerForLazyResolveWithJava( moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope, moduleClassResolver, CompilerEnvironment, lookupTracker, packagePartProvider, jvmTarget, languageVersionSettings, - useBuiltInsProvider = true, useLazyResolve = false, useJavac = useJavac + useBuiltInsProvider = true, useJavac = useJavac ) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt index a96a3990e01..91379d40c19 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt @@ -97,8 +97,7 @@ object JvmAnalyzerFacade : AnalyzerFacade() { packagePartProvider, jvmTarget, languageVersionSettings, - useBuiltInsProvider = false, // TODO: load built-ins from module dependencies in IDE - useLazyResolve = true + useBuiltInsProvider = false // TODO: load built-ins from module dependencies in IDE ) StorageComponentContainerContributor.getInstances(project).forEach { it.onContainerComposed(container, moduleInfo) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/DefaultAnalyzerFacade.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/DefaultAnalyzerFacade.kt index e7208eed07b..137f617501c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/DefaultAnalyzerFacade.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/DefaultAnalyzerFacade.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.container.useInstance -import org.jetbrains.kotlin.context.LazyResolveToken import org.jetbrains.kotlin.context.ModuleContext import org.jetbrains.kotlin.context.ProjectContext import org.jetbrains.kotlin.descriptors.ModuleDescriptor @@ -144,7 +143,6 @@ object DefaultAnalyzerFacade : AnalyzerFacade() { useInstance(metadataFinderFactory.create(moduleContentScope)) targetEnvironment.configure(this) - useImpl() } override val targetPlatform: TargetPlatform diff --git a/compiler/frontend/src/org/jetbrains/kotlin/context/context.kt b/compiler/frontend/src/org/jetbrains/kotlin/context/context.kt index bdc899913d0..c5bbc5c4487 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/context/context.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/context/context.kt @@ -104,15 +104,3 @@ fun ContextForNewModule( val module = ModuleDescriptorImpl(moduleName, projectContext.storageManager, builtIns, multiTargetPlatform) 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 -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt index 9176bc16181..ec3286c23f3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.container.useInstance -import org.jetbrains.kotlin.context.LazyResolveToken import org.jetbrains.kotlin.context.ModuleContext import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor import org.jetbrains.kotlin.incremental.components.LookupTracker @@ -161,7 +160,6 @@ fun createContainerForLazyResolve( useImpl() targetEnvironment.configure(this) - useImpl() useImpl() } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolutionContext.java index 9e2e7e4bbdf..90f8be301a4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolutionContext.java @@ -24,24 +24,18 @@ public class TypeResolutionContext { public final BindingTrace trace; public final boolean checkBounds; public final boolean allowBareTypes; - public final boolean forceResolveLazyTypes; public final boolean isDebuggerContext; public final boolean abbreviated; 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) { - this(scope, trace, checkBounds, allowBareTypes, allowBareTypes, isDebuggerContext, abbreviated); - } - - private TypeResolutionContext( + public TypeResolutionContext( @NotNull LexicalScope scope, @NotNull BindingTrace trace, boolean checkBounds, boolean allowBareTypes, - boolean forceResolveLazyTypes, boolean isDebuggerContext, boolean abbreviated ) { @@ -49,12 +43,12 @@ public class TypeResolutionContext { this.trace = trace; this.checkBounds = checkBounds; this.allowBareTypes = allowBareTypes; - this.forceResolveLazyTypes = forceResolveLazyTypes; this.isDebuggerContext = isDebuggerContext; this.abbreviated = abbreviated; } + @NotNull public TypeResolutionContext noBareTypes() { - return new TypeResolutionContext(scope, trace, checkBounds, false, forceResolveLazyTypes, isDebuggerContext, abbreviated); + return new TypeResolutionContext(scope, trace, checkBounds, false, isDebuggerContext, abbreviated); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 039b906da3e..724bd250f34 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -20,7 +20,6 @@ import com.intellij.util.SmartList import org.jetbrains.kotlin.builtins.createFunctionType import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.context.TypeLazinessToken import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations @@ -62,11 +61,9 @@ class TypeResolver( private val qualifiedExpressionResolver: QualifiedExpressionResolver, private val moduleDescriptor: ModuleDescriptor, private val typeTransformerForTests: TypeTransformerForTests, - private val lazinessToken: TypeLazinessToken, private val dynamicTypesSettings: DynamicTypesSettings, private val dynamicCallableDescriptors: DynamicCallableDescriptors, private val identifierChecker: IdentifierChecker, - private val wrappedTypeFactory: WrappedTypeFactory, private val platformToKotlinClassMap: PlatformToKotlinClassMap, private val languageVersionSettings: LanguageVersionSettings ) { @@ -115,37 +112,16 @@ class TypeResolver( 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 type = resolveTypeElement(c, annotations, typeReference.modifierList, typeElement) + val type = resolveTypeElement(c, annotations, typeReference.modifierList, typeReference.typeElement) c.trace.recordScope(c.scope, typeReference) if (!type.isBare) { for (argument in type.actualType.arguments) { forceResolveTypeContents(argument.type) } + c.trace.record(resolvedTypeSlice, typeReference, type.actualType) } - return type } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/WrappedTypeFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/WrappedTypeFactory.kt index 4fdb2f666ca..525c0cd1987 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/WrappedTypeFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/WrappedTypeFactory.kt @@ -20,7 +20,9 @@ import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.storage.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 = DeferredType.create(storageManager, trace, computation) - open fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType = DeferredType.createRecursionIntolerant(storageManager, trace, computation) -} \ No newline at end of file + open fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType = + DeferredType.create(storageManager, trace, computation) + + open fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType): KotlinType = + DeferredType.createRecursionIntolerant(storageManager, trace, computation) +} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt index 626abf15b5c..c6489fcb63b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/lightClasses/IDELightClassContexts.kt @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.container.useInstance -import org.jetbrains.kotlin.context.LazyResolveToken import org.jetbrains.kotlin.context.ModuleContext import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor @@ -270,8 +269,6 @@ object IDELightClassContexts { useImpl() useInstance(object : WrappedTypeFactory(sm) { - override fun createLazyWrappedType(computation: () -> KotlinType): KotlinType = errorType() - override fun createDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType() override fun createRecursionIntolerantDeferredType(trace: BindingTrace, computation: () -> KotlinType) = errorType() @@ -280,7 +277,6 @@ object IDELightClassContexts { }) IdeaEnvironment.configure(this) - useImpl() useImpl() } diff --git a/idea/testData/checker/TypeArgumentsNotAllowed.kt b/idea/testData/checker/TypeArgumentsNotAllowed.kt index b20f385acac..b6ba2b892af 100644 --- a/idea/testData/checker/TypeArgumentsNotAllowed.kt +++ b/idea/testData/checker/TypeArgumentsNotAllowed.kt @@ -2,6 +2,6 @@ package foo open class A -fun f(t: T<T>) {} +fun f(t: T) {} -fun use(b: foo.A) {} \ No newline at end of file +fun use(b: foo.A) {}