Fix incremental analysis in case of property does not have initializer but could be initialized on a class level
#KT-35028 Fixed
This commit is contained in:
+8
@@ -235,6 +235,14 @@ private class MergedDiagnostics(val diagnostics: Collection<Diagnostic>, overrid
|
|||||||
override fun noSuppression() = this
|
override fun noSuppression() = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep in mind: trace fallbacks to [resolveContext] (is used during resolve) that does not have any
|
||||||
|
* traces of earlier resolve for this [element]
|
||||||
|
*
|
||||||
|
* When trace turned into [BindingContext] it fallbacks to [parentContext]:
|
||||||
|
* It is expected that all slices specific to [element] (and its descendants) are stored in this binding context
|
||||||
|
* and for the rest elements it falls back to [parentContext].
|
||||||
|
*/
|
||||||
private class StackedCompositeBindingContextTrace(
|
private class StackedCompositeBindingContextTrace(
|
||||||
val depth: Int, // depth of stack over original ktFile bindingContext
|
val depth: Int, // depth of stack over original ktFile bindingContext
|
||||||
val element: KtElement,
|
val element: KtElement,
|
||||||
|
|||||||
+13
-1
@@ -238,7 +238,19 @@ class KotlinCodeBlockModificationListener(
|
|||||||
// adding annotations to accessor is the same as change contract of property
|
// adding annotations to accessor is the same as change contract of property
|
||||||
(element !is KtAnnotated || element.annotationEntries.isEmpty())
|
(element !is KtAnnotated || element.annotationEntries.isEmpty())
|
||||||
}
|
}
|
||||||
?.let { return BlockModificationScopeElement(blockDeclaration, it) }
|
?.let { expression ->
|
||||||
|
val declaration = if (blockDeclaration.initializer != null)
|
||||||
|
blockDeclaration
|
||||||
|
else
|
||||||
|
KtPsiUtil.getTopmostParentOfTypes(
|
||||||
|
blockDeclaration,
|
||||||
|
// property could be initialized on a class level
|
||||||
|
KtClass::class.java,
|
||||||
|
// ktFile to check top level property declarations
|
||||||
|
KtFile::class.java
|
||||||
|
) as KtElement
|
||||||
|
return BlockModificationScopeElement(declaration, expression)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user