Create actual fix: add empty brackets for classes in super-type lists
Related to KT-21082
This commit is contained in:
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
|
||||
import org.jetbrains.kotlin.idea.core.*
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.actualsForExpected
|
||||
@@ -41,6 +42,7 @@ import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.MultiTargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.getMultiTargetPlatform
|
||||
|
||||
@@ -259,6 +261,16 @@ internal fun KtPsiFactory.generateClassOrObjectByExpectedClass(
|
||||
}
|
||||
}
|
||||
|
||||
val context = expectedClass.analyze()
|
||||
actualClass.superTypeListEntries.zip(expectedClass.superTypeListEntries).forEach { (actualEntry, expectedEntry) ->
|
||||
if (actualEntry !is KtSuperTypeEntry) return@forEach
|
||||
val superType = context[BindingContext.TYPE, expectedEntry.typeReference]
|
||||
val superClassDescriptor = superType?.constructor?.declarationDescriptor as? ClassDescriptor ?: return@forEach
|
||||
if (superClassDescriptor.kind == ClassKind.CLASS || superClassDescriptor.kind == ClassKind.ENUM_CLASS) {
|
||||
actualEntry.replace(createSuperTypeCallEntry("${actualEntry.typeReference!!.text}()"))
|
||||
}
|
||||
}
|
||||
|
||||
declLoop@ for (expectedDeclaration in expectedClass.declarations.filter { !it.exists() }) {
|
||||
val descriptor = expectedDeclaration.toDescriptor() ?: continue
|
||||
val actualDeclaration: KtDeclaration = when (expectedDeclaration) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Sealed: to be implemented
|
||||
actual sealed class Sealed {
|
||||
actual object Obj : Sealed
|
||||
actual class Klass actual constructor(x: Int) : Sealed
|
||||
actual object Obj : Sealed()
|
||||
actual class Klass actual constructor(x: Int) : Sealed()
|
||||
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
actual sealed class Sealed
|
||||
|
||||
actual object Obj : Sealed()
|
||||
actual class Klass actual constructor(x: Int) : Sealed
|
||||
actual class Klass actual constructor(x: Int) : Sealed()
|
||||
Reference in New Issue
Block a user