[FIR] Add testcases to throw class with unresolved parent.
^KT-60048 Fixed
This commit is contained in:
committed by
Space Team
parent
69b2e2c0ba
commit
3e2c662b6b
+8
-3
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.builtins.StandardNames
|
|||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.ConeTypeCompatibilityChecker.getSuperTypes
|
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier
|
import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier
|
||||||
@@ -22,6 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
|||||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenFunctions
|
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenFunctions
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
@@ -160,8 +160,13 @@ object FirNativeThrowsChecker : FirBasicDeclarationChecker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this is FirResolvedQualifier && symbol?.getSuperTypes()?.any { it.hasError() } == true) {
|
if (this is FirResolvedQualifier) {
|
||||||
return true
|
symbol?.let { symbol ->
|
||||||
|
if (symbol is FirTypeAliasSymbol && symbol.resolvedExpandedTypeRef.coneTypeSafe<ConeKotlinType>()?.hasError() == true) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// TODO: accept also FirClassSymbol<*>, like `FirClassLikeSymbol<*>.getSuperTypes()` does. Write test for this use-case.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -355,7 +355,7 @@ object ConeTypeCompatibilityChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FirClassLikeSymbol<*>.getSuperTypes(): List<ConeClassLikeType> {
|
private fun FirClassLikeSymbol<*>.getSuperTypes(): List<ConeClassLikeType> {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirTypeAliasSymbol -> listOfNotNull(resolvedExpandedTypeRef.coneTypeSafe())
|
is FirTypeAliasSymbol -> listOfNotNull(resolvedExpandedTypeRef.coneTypeSafe())
|
||||||
is FirClassSymbol<*> -> resolvedSuperTypeRefs.mapNotNull { it.coneTypeSafe() }
|
is FirClassSymbol<*> -> resolvedSuperTypeRefs.mapNotNull { it.coneTypeSafe() }
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ fun throwsEmptyParens() {}
|
|||||||
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||||
fun throwsUnresolved() {}
|
fun throwsUnresolved() {}
|
||||||
|
|
||||||
|
class Orphan : <!UNRESOLVED_REFERENCE!>MyUnresolvedParent<!>
|
||||||
|
@Throws(<!ARGUMENT_TYPE_MISMATCH!>Orphan::class<!>)
|
||||||
|
fun throwsClassWithUnresolvedParent() {}
|
||||||
|
|
||||||
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ARGUMENT_TYPE_MISMATCH, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ARGUMENT_TYPE_MISMATCH, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||||
fun throwsNamedUnresolved() {}
|
fun throwsNamedUnresolved() {}
|
||||||
|
|
||||||
@@ -312,6 +316,9 @@ suspend fun suspendThrowsSpreadArrayOfUnresolved() {}
|
|||||||
@Throws(UEAlias::class)
|
@Throws(UEAlias::class)
|
||||||
suspend fun suspendThrowsTypealiasToUnresolved() {}
|
suspend fun suspendThrowsTypealiasToUnresolved() {}
|
||||||
|
|
||||||
|
@Throws(<!ARGUMENT_TYPE_MISMATCH!>Orphan::class<!>)
|
||||||
|
suspend fun suspendThrowsClassWithUnresolvedParent() {}
|
||||||
|
|
||||||
@Throws(Exception1::class, CancellationException::class)
|
@Throws(Exception1::class, CancellationException::class)
|
||||||
suspend fun suspendThrowsCancellationException1() {}
|
suspend fun suspendThrowsCancellationException1() {}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ fun throwsEmptyParens() {}
|
|||||||
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||||
fun throwsUnresolved() {}
|
fun throwsUnresolved() {}
|
||||||
|
|
||||||
|
class Orphan : <!UNRESOLVED_REFERENCE!>MyUnresolvedParent<!>
|
||||||
|
@Throws(<!TYPE_MISMATCH!>Orphan::class<!>)
|
||||||
|
fun throwsClassWithUnresolvedParent() {}
|
||||||
|
|
||||||
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||||
fun throwsNamedUnresolved() {}
|
fun throwsNamedUnresolved() {}
|
||||||
|
|
||||||
@@ -312,6 +316,9 @@ suspend fun suspendThrowsSpreadArrayOfUnresolved() {}
|
|||||||
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>UEAlias::class<!>)
|
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>UEAlias::class<!>)
|
||||||
suspend fun suspendThrowsTypealiasToUnresolved() {}
|
suspend fun suspendThrowsTypealiasToUnresolved() {}
|
||||||
|
|
||||||
|
<!MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND!>@Throws(<!TYPE_MISMATCH!>Orphan::class<!>)<!>
|
||||||
|
suspend fun suspendThrowsClassWithUnresolvedParent() {}
|
||||||
|
|
||||||
@Throws(Exception1::class, CancellationException::class)
|
@Throws(Exception1::class, CancellationException::class)
|
||||||
suspend fun suspendThrowsCancellationException1() {}
|
suspend fun suspendThrowsCancellationException1() {}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package
|
|||||||
@kotlin.Throws(exceptionClasses = {Exception1::class, kotlin.coroutines.cancellation.CancellationException::class}) public suspend fun suspendThrowsCancellationException1(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {Exception1::class, kotlin.coroutines.cancellation.CancellationException::class}) public suspend fun suspendThrowsCancellationException1(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {kotlin.coroutines.cancellation.CancellationException::class, Exception1::class}) public suspend fun suspendThrowsCancellationException2(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {kotlin.coroutines.cancellation.CancellationException::class, Exception1::class}) public suspend fun suspendThrowsCancellationException2(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {kotlin.coroutines.cancellation.CancellationException::class}) public suspend fun suspendThrowsCancellationExceptionTypealias(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {kotlin.coroutines.cancellation.CancellationException::class}) public suspend fun suspendThrowsCancellationExceptionTypealias(): kotlin.Unit
|
||||||
|
@kotlin.Throws(exceptionClasses = {Orphan::class}) public suspend fun suspendThrowsClassWithUnresolvedParent(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {kotlin.Exception::class}) public suspend fun suspendThrowsException1(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {kotlin.Exception::class}) public suspend fun suspendThrowsException1(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {Exception1::class, kotlin.Exception::class}) public suspend fun suspendThrowsException2(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {Exception1::class, kotlin.Exception::class}) public suspend fun suspendThrowsException2(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {kotlin.Exception::class}) public suspend fun suspendThrowsExceptionTypealias(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {kotlin.Exception::class}) public suspend fun suspendThrowsExceptionTypealias(): kotlin.Unit
|
||||||
@@ -31,6 +32,7 @@ package
|
|||||||
@kotlin.Throws(exceptionClasses = {kotlin.Throwable::class}) public suspend fun suspendThrowsThrowableTypealias(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {kotlin.Throwable::class}) public suspend fun suspendThrowsThrowableTypealias(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {}) public suspend fun suspendThrowsTypealiasToUnresolved(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {}) public suspend fun suspendThrowsTypealiasToUnresolved(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {}) public suspend fun suspendThrowsUnresolved(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {}) public suspend fun suspendThrowsUnresolved(): kotlin.Unit
|
||||||
|
@kotlin.Throws(exceptionClasses = {Orphan::class}) public fun throwsClassWithUnresolvedParent(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {}) public fun throwsEmptyParens(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {}) public fun throwsEmptyParens(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {}) public fun throwsNamedArrayOfUnresolved(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {}) public fun throwsNamedArrayOfUnresolved(): kotlin.Unit
|
||||||
@kotlin.Throws(exceptionClasses = {}) public fun throwsNamedEmptyArrayOf(): kotlin.Unit
|
@kotlin.Throws(exceptionClasses = {}) public fun throwsNamedEmptyArrayOf(): kotlin.Unit
|
||||||
@@ -245,6 +247,13 @@ public final class InheritsThrowsAndNoThrows : Base0, Base1 {
|
|||||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class Orphan {
|
||||||
|
public constructor Orphan()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
public final class OverrideDifferentThrows4 : OverridesDifferentThrows3 {
|
public final class OverrideDifferentThrows4 : OverridesDifferentThrows3 {
|
||||||
public constructor OverrideDifferentThrows4()
|
public constructor OverrideDifferentThrows4()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user