[FIR] Resolve array literal with non-primitive-array expected type as arrayOf call
This lets us properly complete the call which fixes some issues with false-positive type mismatches. This change doesn't apply to array literals in annotation calls yet because they are resolved as context-dependent. This will be adapted in a following commit. #KT-59581
This commit is contained in:
committed by
Space Team
parent
4ead02271b
commit
ff6b3350ae
+1
-1
@@ -41,7 +41,7 @@ object FirAnnotationExpressionChecker : FirAnnotationCallChecker() {
|
||||
val argumentMapping = expression.argumentMapping.mapping
|
||||
val fqName = expression.fqName(context.session)
|
||||
for (arg in argumentMapping.values) {
|
||||
val argExpression = (arg as? FirNamedArgumentExpression)?.expression ?: arg
|
||||
val argExpression = (arg as? FirNamedArgumentExpression)?.expression ?: (arg as? FirErrorExpression)?.expression ?: arg
|
||||
checkAnnotationArgumentWithSubElements(argExpression, context.session, reporter, context)
|
||||
?.let { reporter.reportOn(argExpression.source, it, context) }
|
||||
}
|
||||
|
||||
+2
-6
@@ -18,11 +18,7 @@ import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.isArrayType
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
|
||||
object FirNamedVarargChecker : FirCallChecker() {
|
||||
override fun check(expression: FirCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
@@ -74,7 +70,7 @@ object FirNamedVarargChecker : FirCallChecker() {
|
||||
|
||||
if (expression is FirArrayOfCall) {
|
||||
// FirArrayOfCall has the `vararg` argument expression pre-flattened and doesn't have an argument mapping.
|
||||
expression.arguments.forEach { checkArgument(it, it is FirNamedArgumentExpression, null /* not used for annotation call */) }
|
||||
expression.arguments.forEach { checkArgument(it, it is FirNamedArgumentExpression, expression.typeRef.coneTypeOrNull) }
|
||||
} else {
|
||||
val argumentMap = expression.resolvedArgumentMapping ?: return
|
||||
for ((argument, parameter) in argumentMap) {
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ object FirUnsupportedArrayLiteralChecker : FirArrayOfCallChecker() {
|
||||
|
||||
for (unwrapped in unwrappedArguments) {
|
||||
if (unwrapped == expression ||
|
||||
(unwrapped is FirErrorExpression && unwrapped.expression == expression) ||
|
||||
unwrapped is FirArrayOfCall &&
|
||||
unwrapped.arguments.any { arrayOfCallElement -> arrayOfCallElement.unwrapArgument() == expression }
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user