Fix handling of nullable types in LetImplementInterfaceFix #KT-11404
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3056e0b54c
commit
f9bef68e10
@@ -38,15 +38,19 @@ class LetImplementInterfaceFix(
|
||||
|
||||
private fun KotlinType.renderShort() = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
|
||||
private val expectedTypeName = expectedType.renderShort()
|
||||
private val expectedTypeName: String
|
||||
|
||||
private val expectedTypeNameSourceCode = IdeDescriptorRenderers.SOURCE_CODE.renderType(expectedType)
|
||||
private val expectedTypeNameSourceCode: String
|
||||
|
||||
private val prefix: String
|
||||
|
||||
private val validExpectedType: Boolean
|
||||
|
||||
init {
|
||||
val expectedTypeNotNullable = TypeUtils.makeNotNullable(expectedType)
|
||||
expectedTypeName = expectedTypeNotNullable.renderShort()
|
||||
expectedTypeNameSourceCode = IdeDescriptorRenderers.SOURCE_CODE.renderType(expectedTypeNotNullable)
|
||||
|
||||
val verb = if (expressionType.isInterface()) "extend" else "implement"
|
||||
prefix = "Let '${expressionType.renderShort()}' $verb"
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Let 'B' implement interface 'A'" "true"
|
||||
package let.implement
|
||||
|
||||
fun bar() {
|
||||
foo(B()<caret>)
|
||||
}
|
||||
|
||||
|
||||
fun foo(a: A?) {
|
||||
}
|
||||
|
||||
interface A
|
||||
class B
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Let 'B' implement interface 'A'" "true"
|
||||
package let.implement
|
||||
|
||||
fun bar() {
|
||||
foo(B()<caret>)
|
||||
}
|
||||
|
||||
|
||||
fun foo(a: A?) {
|
||||
}
|
||||
|
||||
interface A
|
||||
class B : A
|
||||
@@ -7366,6 +7366,13 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("letClassImplementInterfaceNullable.kt")
|
||||
public void testLetClassImplementInterfaceNullable() throws Exception {
|
||||
String fileName =
|
||||
KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/letClassImplementInterfaceNullable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("letInterfaceExtendInterface.kt")
|
||||
public void testLetInterfaceExtendInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/letInterfaceExtendInterface.kt");
|
||||
|
||||
Reference in New Issue
Block a user