CallableBuilder: fix PIEAE

#EA-214253 Fix
This commit is contained in:
Dmitry Gridin
2019-10-11 09:27:34 +07:00
parent 0ac2303fad
commit 20784d50ff
@@ -445,6 +445,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
if (containingElement is KtBlockExpression && (callableInfo as? PropertyInfo)?.writable == true) { if (containingElement is KtBlockExpression && (callableInfo as? PropertyInfo)?.writable == true) {
originalElement as KtBinaryExpression originalElement as KtBinaryExpression
} else null } else null
val pointerOfAssignmentToReplace = assignmentToReplace?.createSmartPointer()
val ownerTypeString = if (isExtension) { val ownerTypeString = if (isExtension) {
val renderedType = receiverTypeCandidate!!.renderedTypes.first() val renderedType = receiverTypeCandidate!!.renderedTypes.first()
@@ -575,9 +576,10 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
} }
} }
if (assignmentToReplace != null) { val newInitializer = pointerOfAssignmentToReplace?.element
(declaration as KtProperty).initializer = assignmentToReplace.right if (newInitializer != null) {
return assignmentToReplace.replace(declaration) as KtCallableDeclaration (declaration as KtProperty).initializer = newInitializer.right
return newInitializer.replace(declaration) as KtCallableDeclaration
} }
val container = if (containingElement is KtClass && callableInfo.isForCompanion) { val container = if (containingElement is KtClass && callableInfo.isForCompanion) {