[FIR] Consider fullyExpandedType instead of original type in isSubtypeForTypeMismatch, consider lookupTag in isError method
This commit is contained in:
committed by
teamcityserver
parent
0b0a96a1d3
commit
da15f0ffe8
@@ -382,8 +382,10 @@ private fun lowerThanBound(context: ConeInferenceContext, argument: ConeKotlinTy
|
|||||||
fun FirMemberDeclaration.isInlineOnly(): Boolean = isInline && hasAnnotation(INLINE_ONLY_ANNOTATION_CLASS_ID)
|
fun FirMemberDeclaration.isInlineOnly(): Boolean = isInline && hasAnnotation(INLINE_ONLY_ANNOTATION_CLASS_ID)
|
||||||
|
|
||||||
fun isSubtypeForTypeMismatch(context: ConeInferenceContext, subtype: ConeKotlinType, supertype: ConeKotlinType): Boolean {
|
fun isSubtypeForTypeMismatch(context: ConeInferenceContext, subtype: ConeKotlinType, supertype: ConeKotlinType): Boolean {
|
||||||
return AbstractTypeChecker.isSubtypeOf(context, subtype, supertype)
|
val subtypeFullyExpanded = subtype.fullyExpandedType(context.session)
|
||||||
|| isSubtypeOfForFunctionalTypeReturningUnit(context.session.typeContext, subtype, supertype)
|
val supertypeFullyExpanded = supertype.fullyExpandedType(context.session)
|
||||||
|
return AbstractTypeChecker.isSubtypeOf(context, subtypeFullyExpanded, supertypeFullyExpanded)
|
||||||
|
|| isSubtypeOfForFunctionalTypeReturningUnit(context.session.typeContext, subtypeFullyExpanded, supertypeFullyExpanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSubtypeOfForFunctionalTypeReturningUnit(
|
private fun isSubtypeOfForFunctionalTypeReturningUnit(
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
|||||||
|
|
||||||
override fun KotlinTypeMarker.isError(): Boolean {
|
override fun KotlinTypeMarker.isError(): Boolean {
|
||||||
assert(this is ConeKotlinType)
|
assert(this is ConeKotlinType)
|
||||||
return this is ConeClassErrorType || this is ConeKotlinErrorType || this.typeConstructor().isError()
|
return this is ConeClassErrorType || this is ConeKotlinErrorType || this.typeConstructor().isError() ||
|
||||||
|
(this is ConeClassLikeType && this.lookupTag is ConeClassLikeErrorLookupTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun KotlinTypeMarker.isUninferredParameter(): Boolean {
|
override fun KotlinTypeMarker.isUninferredParameter(): Boolean {
|
||||||
|
|||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
class Foo<out T>(val baz: Baz<T>)
|
|
||||||
|
|
||||||
class Bar {
|
|
||||||
val foo: Foo<*> = TODO()
|
|
||||||
|
|
||||||
fun <T> bar(): Baz<T> {
|
|
||||||
return <!RETURN_TYPE_MISMATCH!>foo.baz<!>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typealias Baz<T> = (@UnsafeVariance T) -> Unit
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
class Foo<out T>(val baz: Baz<T>)
|
class Foo<out T>(val baz: Baz<T>)
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fun main() {
|
|||||||
a.baz(listOf())
|
a.baz(listOf())
|
||||||
|
|
||||||
a.manyParams(null)
|
a.manyParams(null)
|
||||||
a.<!NONE_APPLICABLE!>manyParams<!>(any<kotlin.jvm.functions.FunctionN<Unit>>())
|
a.manyParams(any<kotlin.jvm.functions.FunctionN<Unit>>())
|
||||||
|
|
||||||
// Potentially, this would have better to forbid calling manyParams, too.
|
// Potentially, this would have better to forbid calling manyParams, too.
|
||||||
// But it might be complicated because we need to match that it is an override
|
// But it might be complicated because we need to match that it is an override
|
||||||
|
|||||||
Reference in New Issue
Block a user