"Let type implement interface": don't suggest same type #KT-25928 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-08-10 05:40:00 +03:00
committed by Mikhail Glukhikh
parent 2d2f1125a9
commit 6fbf6b0a93
3 changed files with 18 additions and 1 deletions
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.KotlinTypeFactory
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.*
import java.util.*
@@ -120,7 +121,9 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() {
val expressionTypeDeclaration = expressionType.constructor.declarationDescriptor?.let {
DescriptorToSourceUtils.descriptorToDeclaration(it)
} as? KtClassOrObject
expressionTypeDeclaration?.let { actions.add(LetImplementInterfaceFix(it, expectedType, expressionType)) }
if (expressionTypeDeclaration != null && expectedType != TypeUtils.makeNotNullable(expressionType)) {
actions.add(LetImplementInterfaceFix(expressionTypeDeclaration, expectedType, expressionType))
}
}