mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-36968 Fix conjunction type check
GitOrigin-RevId: d9339a2ab403104a7bcc9438746c0452eb279c1b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
19f6212313
commit
0f19321e61
+5
@@ -152,6 +152,11 @@ public abstract class K2PostfixTemplateTestGenerated extends AbstractK2PostfixTe
|
||||
performTest();
|
||||
}
|
||||
|
||||
@TestMetadata("conjunctionType.kt")
|
||||
public void testConjunctionType() throws Exception {
|
||||
performTest();
|
||||
}
|
||||
|
||||
@TestMetadata("forOnMap.kt")
|
||||
public void testForOnMap() throws Exception {
|
||||
performTest();
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
open class Foo
|
||||
abstract class AbstractFoo : Foo(), Iterable<Int>
|
||||
|
||||
fun test(a: Iterable<*>) {
|
||||
if (a is Foo) {
|
||||
for (<selection>any<caret></selection> in a) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
open class Foo
|
||||
abstract class AbstractFoo : Foo(), Iterable<Int>
|
||||
|
||||
fun test(a: Iterable<*>) {
|
||||
if (a is Foo) {
|
||||
a<caret>
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -4,7 +4,7 @@ package org.jetbrains.kotlin.idea.codeinsight.utils
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.kotlin.analysis.api.KaContextParameterApi
|
||||
import org.jetbrains.kotlin.analysis.api.KaSession
|
||||
import org.jetbrains.kotlin.analysis.api.components.DefaultTypeClassIds
|
||||
import org.jetbrains.kotlin.analysis.api.components.KaStandardTypeClassIds
|
||||
import org.jetbrains.kotlin.analysis.api.components.allSupertypes
|
||||
import org.jetbrains.kotlin.analysis.api.components.isMarkedNullable
|
||||
import org.jetbrains.kotlin.analysis.api.components.lowerBoundIfFlexible
|
||||
@@ -17,9 +17,9 @@ private val ITERABLE_CLASS_IDS: Set<ClassId> = buildSet {
|
||||
this += StandardClassIds.primitiveArrayTypeByElementType.values // What about elementTypeByUnsignedArrayType?
|
||||
this += StandardClassIds.Iterable
|
||||
this += StandardClassIds.Map
|
||||
this += ClassId.fromString("kotlin/sequences/Sequence")
|
||||
this += StandardClassIds.Sequence
|
||||
this += ClassId.fromString("java/util/stream/Stream")
|
||||
this += DefaultTypeClassIds.CHAR_SEQUENCE
|
||||
this += KaStandardTypeClassIds.CHAR_SEQUENCE
|
||||
}
|
||||
|
||||
@OptIn(KaContextParameterApi::class)
|
||||
@@ -40,7 +40,7 @@ context(_: KaSession)
|
||||
private fun KaType.isInheritorOf(classIds: Set<ClassId>, checkNullability: Boolean = true): Boolean {
|
||||
return when (this) {
|
||||
is KaFlexibleType -> this.lowerBoundIfFlexible().isInheritorOf(classIds)
|
||||
is KaIntersectionType -> this.conjuncts.all { it.isInheritorOf(classIds) }
|
||||
is KaIntersectionType -> this.conjuncts.any { it.isInheritorOf(classIds) }
|
||||
is KaDefinitelyNotNullType -> this.original.isInheritorOf(classIds, checkNullability = false)
|
||||
is KaTypeParameterType -> symbol.upperBounds.any { it.isInheritorOf(classIds) }
|
||||
is KaClassType -> {
|
||||
|
||||
Reference in New Issue
Block a user