KT-11404 (let type implement interface): indirect inheritance with generics fixed

This commit is contained in:
Mikhail Glukhikh
2016-04-04 14:17:56 +03:00
parent 640ae60a6b
commit b55610b1f0
2 changed files with 8 additions and 6 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.isInterface import org.jetbrains.kotlin.types.typeUtil.isInterface
class LetImplementInterfaceFix( class LetImplementInterfaceFix(
@@ -52,7 +53,7 @@ class LetImplementInterfaceFix(
validExpectedType = with (expectedType) { validExpectedType = with (expectedType) {
isInterface() && isInterface() &&
!containsStarProjections() && !containsStarProjections() &&
constructor !in expressionType.constructor.supertypes.map(KotlinType::getConstructor) constructor !in TypeUtils.getAllSupertypes(expressionType).map(KotlinType::getConstructor)
} }
} }
@@ -1,6 +1,7 @@
// "Let 'B' implement interface 'A'" "false" // "Let 'B' implement interface 'A<Int>'" "false"
// ACTION: Add 'a =' to argument // ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'B'
// ACTION: Convert to expression body // ACTION: Convert to expression body
// ERROR: Type mismatch: inferred type is B but A<Int> was expected
package let.implement package let.implement
fun bar() { fun bar() {
@@ -8,9 +9,9 @@ fun bar() {
} }
fun foo(a: A) { fun foo(a: A<Int>) {
} }
interface A interface A<T>
interface InBetween : A interface InBetween : A<String>
class B : InBetween class B : InBetween