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
This commit is contained in:
Pavel V. Talanov
2016-04-05 15:00:21 +03:00
parent 74091a12cf
commit f7db1f934c
@@ -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)
}