FIR checkers: report SMARTCAST_IMPOSSIBLE
This commit is contained in:
committed by
TeamCityServer
parent
2bb7ef9747
commit
ce767046eb
+2
-2
@@ -85,7 +85,7 @@ private fun checkExpressionArgument(
|
||||
if (argumentType.isMarkedNullable) {
|
||||
if (csBuilder.addSubtypeConstraintIfCompatible(argumentType, actualExpectedType, position)) return null
|
||||
if (csBuilder.addSubtypeConstraintIfCompatible(argumentType.makeNotNullable(), actualExpectedType, position)) {
|
||||
return ArgumentTypeMismatchDiagnostic(actualExpectedType, argumentType, expressionArgument)
|
||||
return ArgumentNullabilityMismatchDiagnostic(actualExpectedType, argumentType, expressionArgument)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ private fun checkExpressionArgument(
|
||||
|
||||
// Used only for arguments with @NotNull annotation
|
||||
if (expectedType is NotNullTypeVariable && argumentType.isMarkedNullable) {
|
||||
diagnosticsHolder.addDiagnostic(ArgumentTypeMismatchDiagnostic(expectedType, argumentType, expressionArgument))
|
||||
diagnosticsHolder.addDiagnostic(ArgumentNullabilityMismatchDiagnostic(expectedType, argumentType, expressionArgument))
|
||||
}
|
||||
|
||||
if (expressionArgument.isSafeCall) {
|
||||
|
||||
+3
-3
@@ -161,7 +161,7 @@ sealed class UnstableSmartCast(
|
||||
class UnstableSmartCastResolutionError(
|
||||
argument: ExpressionKotlinCallArgument,
|
||||
targetType: UnwrappedType,
|
||||
) : UnstableSmartCast(argument, targetType, MAY_THROW_RUNTIME_ERROR)
|
||||
) : UnstableSmartCast(argument, targetType, UNSTABLE_SMARTCAST)
|
||||
|
||||
class UnstableSmartCastDiagnosticError(
|
||||
argument: ExpressionKotlinCallArgument,
|
||||
@@ -214,11 +214,11 @@ class NonApplicableCallForBuilderInferenceDiagnostic(val kotlinCall: KotlinCall)
|
||||
}
|
||||
}
|
||||
|
||||
class ArgumentTypeMismatchDiagnostic(
|
||||
class ArgumentNullabilityMismatchDiagnostic(
|
||||
val expectedType: UnwrappedType,
|
||||
val actualType: UnwrappedType,
|
||||
val expressionArgument: ExpressionKotlinCallArgument
|
||||
) : KotlinCallDiagnostic(MAY_THROW_RUNTIME_ERROR) {
|
||||
) : KotlinCallDiagnostic(UNSAFE_CALL) {
|
||||
override fun report(reporter: DiagnosticReporter) {
|
||||
reporter.onCallArgument(expressionArgument, this)
|
||||
}
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ object ErrorDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED) // todo discus
|
||||
object LowPriorityDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED_LOW_PRIORITY)
|
||||
object DynamicDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED_LOW_PRIORITY)
|
||||
object ResolvedUsingNewFeatures : ResolutionDiagnostic(RESOLVED_NEED_PRESERVE_COMPATIBILITY)
|
||||
object UnstableSmartCastDiagnostic : ResolutionDiagnostic(MAY_THROW_RUNTIME_ERROR)
|
||||
object UnstableSmartCastDiagnostic : ResolutionDiagnostic(UNSTABLE_SMARTCAST)
|
||||
object HiddenExtensionRelatedToDynamicTypes : ResolutionDiagnostic(HIDDEN)
|
||||
object HiddenDescriptor : ResolutionDiagnostic(HIDDEN)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user