Add actual: handle parameters with val/var as compatible with property
So #KT-23762 Fixed
This commit is contained in:
@@ -48,7 +48,9 @@ class AddActualFix(
|
||||
val factory = KtPsiFactory(element)
|
||||
val pureActualClass = factory.generateClassOrObjectByExpectedClass(
|
||||
project, expectedClass, actualNeeded = true,
|
||||
existingDeclarations = element.declarations + listOfNotNull(element.primaryConstructor)
|
||||
existingDeclarations = element.declarations +
|
||||
element.primaryConstructor?.valueParameters?.filter { it.hasValOrVar() }.orEmpty() +
|
||||
listOfNotNull(element.primaryConstructor)
|
||||
)
|
||||
for (declaration in pureActualClass.declarations) {
|
||||
element.addDeclaration(declaration)
|
||||
|
||||
@@ -230,6 +230,7 @@ internal fun KtPsiFactory.generateClassOrObjectByExpectedClass(
|
||||
name == it.name && when (this) {
|
||||
is KtConstructor<*> -> it is KtConstructor<*> && areCompatible(this, it)
|
||||
is KtNamedFunction -> it is KtNamedFunction && areCompatible(this, it)
|
||||
is KtProperty -> it is KtProperty || it is KtParameter && it.hasValOrVar()
|
||||
else -> this.javaClass == it.javaClass
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user