EmptyIntersectionTypeChecker: fix error in diagnostic text
Related to KT-54411
This commit is contained in:
committed by
Space Team
parent
71c2aac280
commit
832baf81e5
+9
@@ -0,0 +1,9 @@
|
||||
/kt54411.kt:5:68: warning: parameter 'createNewSegment' is never used
|
||||
inline fun <F : Segment<F>> AtomicRef<F>.findSegmentAndMoveForward(createNewSegment: (prev: F?) -> F) = null
|
||||
^
|
||||
/kt54411.kt:14:14: warning: type argument for a type parameter F has possible incompatible upper bounds: Segment<OneElementSegment<Q>>, OneElementSegment<Q>? (final class and non-final class: Segment<OneElementSegment<out Any?>>, OneElementSegment<out Any?>)
|
||||
tail.findSegmentAndMoveForward(::createSegment)
|
||||
^
|
||||
/kt54411.kt:18:31: warning: parameter 'prev' is never used
|
||||
private fun <C> createSegment(prev: OneElementSegment<C>?) = OneElementSegment<C>()
|
||||
^
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||
class AtomicRef<T>(val value: T)
|
||||
|
||||
inline fun <F : Segment<F>> AtomicRef<F>.findSegmentAndMoveForward(createNewSegment: (prev: F?) -> F) = null
|
||||
|
||||
+8
-4
@@ -108,8 +108,9 @@ internal object EmptyIntersectionTypeChecker {
|
||||
|
||||
when {
|
||||
firstSuperTypeWithSecondConstructor != null && secondSuperTypeByFirstConstructor != null -> {
|
||||
val argumentsIntersectionKind =
|
||||
computeByCheckingTypeArguments(firstSuperTypeWithSecondConstructor, secondSuperTypeByFirstConstructor) ?: continue
|
||||
val argumentsIntersectionKind = computeByCheckingTypeArguments(
|
||||
firstSuperTypeWithSecondConstructor, secondSuperTypeByFirstConstructor
|
||||
) ?: continue
|
||||
|
||||
if (argumentsIntersectionKind.kind.isDefinitelyEmpty())
|
||||
return argumentsIntersectionKind
|
||||
@@ -124,8 +125,11 @@ internal object EmptyIntersectionTypeChecker {
|
||||
else -> {
|
||||
// don't have incompatible supertypes so can have a common subtype only if all types are interfaces
|
||||
if (firstTypeConstructor.isFinalClassConstructor() || secondTypeConstructor.isFinalClassConstructor()) {
|
||||
possibleEmptyIntersectionKind =
|
||||
EmptyIntersectionTypeInfo(EmptyIntersectionTypeKind.SINGLE_FINAL_CLASS, firstType, secondType)
|
||||
possibleEmptyIntersectionKind = EmptyIntersectionTypeInfo(
|
||||
if (atLeastOneInterface) EmptyIntersectionTypeKind.FINAL_CLASS_AND_INTERFACE
|
||||
else EmptyIntersectionTypeKind.SINGLE_FINAL_CLASS,
|
||||
firstType, secondType
|
||||
)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ enum class EmptyIntersectionTypeKind(val description: String) {
|
||||
MULTIPLE_CLASSES("multiple incompatible classes"),
|
||||
INCOMPATIBLE_SUPERTYPES("incompatible supertypes"),
|
||||
INCOMPATIBLE_TYPE_ARGUMENTS("incompatible type arguments"),
|
||||
SINGLE_FINAL_CLASS("final class and interface")
|
||||
FINAL_CLASS_AND_INTERFACE("final class and interface"),
|
||||
SINGLE_FINAL_CLASS("final class and non-final class")
|
||||
}
|
||||
|
||||
fun EmptyIntersectionTypeKind.isDefinitelyEmpty(): Boolean =
|
||||
@@ -17,4 +18,5 @@ fun EmptyIntersectionTypeKind.isDefinitelyEmpty(): Boolean =
|
||||
|| this == EmptyIntersectionTypeKind.INCOMPATIBLE_SUPERTYPES
|
||||
|| this == EmptyIntersectionTypeKind.INCOMPATIBLE_TYPE_ARGUMENTS
|
||||
|
||||
fun EmptyIntersectionTypeKind.isPossiblyEmpty(): Boolean = this == EmptyIntersectionTypeKind.SINGLE_FINAL_CLASS
|
||||
fun EmptyIntersectionTypeKind.isPossiblyEmpty(): Boolean =
|
||||
this == EmptyIntersectionTypeKind.SINGLE_FINAL_CLASS || this == EmptyIntersectionTypeKind.FINAL_CLASS_AND_INTERFACE
|
||||
|
||||
Reference in New Issue
Block a user