KT-11404 (let type implement interface): indirect inheritance with generics fixed
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
// "Let 'B' implement interface 'A'" "false"
|
||||
// ACTION: Add 'a =' to argument
|
||||
// "Let 'B' implement interface 'A<Int>'" "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<Int> was expected
|
||||
package let.implement
|
||||
|
||||
fun bar() {
|
||||
@@ -8,9 +9,9 @@ fun bar() {
|
||||
}
|
||||
|
||||
|
||||
fun foo(a: A) {
|
||||
fun foo(a: A<Int>) {
|
||||
}
|
||||
|
||||
interface A
|
||||
interface InBetween : A
|
||||
interface A<T>
|
||||
interface InBetween : A<String>
|
||||
class B : InBetween
|
||||
|
||||
Reference in New Issue
Block a user