From b55610b1f08d4cbb52b20233491120b749df4e35 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 4 Apr 2016 14:17:56 +0300 Subject: [PATCH] KT-11404 (let type implement interface): indirect inheritance with generics fixed --- .../kotlin/idea/quickfix/LetImplementInterfaceFix.kt | 3 ++- .../letClassImplementIndirectlyInheritedInterface.kt | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/LetImplementInterfaceFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/LetImplementInterfaceFix.kt index c73a7fe35e0..f0e398c0c01 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/LetImplementInterfaceFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/LetImplementInterfaceFix.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.isInterface class LetImplementInterfaceFix( @@ -52,7 +53,7 @@ class LetImplementInterfaceFix( validExpectedType = with (expectedType) { isInterface() && !containsStarProjections() && - constructor !in expressionType.constructor.supertypes.map(KotlinType::getConstructor) + constructor !in TypeUtils.getAllSupertypes(expressionType).map(KotlinType::getConstructor) } } diff --git a/idea/testData/quickfix/typeMismatch/letClassImplementIndirectlyInheritedInterface.kt b/idea/testData/quickfix/typeMismatch/letClassImplementIndirectlyInheritedInterface.kt index 9714b142767..dc7bd0316cd 100644 --- a/idea/testData/quickfix/typeMismatch/letClassImplementIndirectlyInheritedInterface.kt +++ b/idea/testData/quickfix/typeMismatch/letClassImplementIndirectlyInheritedInterface.kt @@ -1,6 +1,7 @@ -// "Let 'B' implement interface 'A'" "false" -// ACTION: Add 'a =' to argument +// "Let 'B' implement interface 'A'" "false" +// ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'B' // ACTION: Convert to expression body +// ERROR: Type mismatch: inferred type is B but A was expected package let.implement fun bar() { @@ -8,9 +9,9 @@ fun bar() { } -fun foo(a: A) { +fun foo(a: A) { } -interface A -interface InBetween : A +interface A +interface InBetween : A class B : InBetween