From f7db1f934ca36ec831552197aa4a5164f59d4c5c Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 5 Apr 2016 15:00:21 +0300 Subject: [PATCH] IDELightClassGenerationSupport#getContextForClassOrObject: do not rely on resolution facade being unchanged ResolutionFacade should only recompute its underlying structures in case of psi change (which is ok) or some exception, but relying on it being unchanged has led to numerous exceptions in backend when building light classes (EA-70985, EA-80756) Changing this code may not be the solution but it can possibly move failures to other parts of the system, where they can be easier diagnosed --- .../idea/caches/resolve/IDELightClassGenerationSupport.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt index c61efd8e67d..3c791096d90 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt @@ -66,7 +66,6 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG private fun getContextForNonLocalClassOrObject(classOrObject: KtClassOrObject): LightClassConstructionContext { val resolutionFacade = classOrObject.getResolutionFacade() - ForceResolveUtil.forceResolveAllContents(resolutionFacade.resolveToDescriptor(classOrObject)) val bindingContext = if (classOrObject is KtClass && classOrObject.isAnnotation()) { // need to make sure default values for parameters are resolved // because java resolve depends on whether there is a default value for an annotation attribute @@ -76,6 +75,10 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG else { resolutionFacade.analyze(classOrObject) } + val classDescriptor = bindingContext.get(BindingContext.CLASS, classOrObject).sure { + "Class descriptor was not found for ${classOrObject.getElementTextWithContext()}" + } + ForceResolveUtil.forceResolveAllContents(classDescriptor) return LightClassConstructionContext(bindingContext, resolutionFacade.moduleDescriptor) }