[FIR] Resolve arguments of error types during type resolution
This commit is contained in:
committed by
Space Team
parent
bc93556dbb
commit
bd26c29229
+1
-1
@@ -127,7 +127,7 @@ private class CalculatorForNestedCall(
|
||||
) {
|
||||
val unwrappedType = type.lowerBoundIfFlexible()
|
||||
val typeArgumentsCount = unwrappedType.argumentsCount()
|
||||
if (typeArgumentsCount > 0) {
|
||||
if (typeArgumentsCount > 0 && !unwrappedType.isError()) {
|
||||
for (position in 0 until typeArgumentsCount) {
|
||||
val argument = unwrappedType.getArgument(position)
|
||||
val parameter = unwrappedType.typeConstructor().getParameter(position)
|
||||
|
||||
+37
-29
@@ -235,34 +235,6 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
TypeResolutionResult.Unresolved -> null to null
|
||||
}
|
||||
|
||||
if (symbol == null || symbol !is FirClassifierSymbol<*>) {
|
||||
val diagnostic = when {
|
||||
symbol?.fir is FirEnumEntry -> {
|
||||
if (isOperandOfIsOperator) {
|
||||
ConeSimpleDiagnostic("'is' operator can not be applied to an enum entry.", DiagnosticKind.IsEnumEntry)
|
||||
} else {
|
||||
ConeSimpleDiagnostic("An enum entry should not be used as a type.", DiagnosticKind.EnumEntryAsType)
|
||||
}
|
||||
}
|
||||
result is TypeResolutionResult.Ambiguity -> {
|
||||
ConeAmbiguityError(typeRef.qualifier.last().name, result.typeCandidates.first().applicability, result.typeCandidates)
|
||||
}
|
||||
else -> {
|
||||
ConeUnresolvedTypeQualifierError(typeRef.qualifier, isNullable = typeRef.isMarkedNullable)
|
||||
}
|
||||
}
|
||||
return ConeErrorType(diagnostic, attributes = typeRef.annotations.computeTypeAttributes(session))
|
||||
}
|
||||
if (symbol is FirTypeParameterSymbol) {
|
||||
for (part in typeRef.qualifier) {
|
||||
if (part.typeArgumentList.typeArguments.isNotEmpty()) {
|
||||
return ConeErrorType(
|
||||
ConeUnexpectedTypeArgumentsError("Type arguments not allowed", part.typeArgumentList.source)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val allTypeArguments = mutableListOf<ConeTypeProjection>()
|
||||
var typeArgumentsCount = 0
|
||||
|
||||
@@ -351,8 +323,44 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
}
|
||||
}
|
||||
|
||||
val resultingArguments = allTypeArguments.toTypedArray()
|
||||
|
||||
if (symbol == null || symbol !is FirClassifierSymbol<*>) {
|
||||
val diagnostic = when {
|
||||
symbol?.fir is FirEnumEntry -> {
|
||||
if (isOperandOfIsOperator) {
|
||||
ConeSimpleDiagnostic("'is' operator can not be applied to an enum entry.", DiagnosticKind.IsEnumEntry)
|
||||
} else {
|
||||
ConeSimpleDiagnostic("An enum entry should not be used as a type.", DiagnosticKind.EnumEntryAsType)
|
||||
}
|
||||
}
|
||||
result is TypeResolutionResult.Ambiguity -> {
|
||||
ConeAmbiguityError(typeRef.qualifier.last().name, result.typeCandidates.first().applicability, result.typeCandidates)
|
||||
}
|
||||
else -> {
|
||||
ConeUnresolvedTypeQualifierError(typeRef.qualifier, isNullable = typeRef.isMarkedNullable)
|
||||
}
|
||||
}
|
||||
return ConeErrorType(
|
||||
diagnostic,
|
||||
typeArguments = resultingArguments,
|
||||
attributes = typeRef.annotations.computeTypeAttributes(session)
|
||||
)
|
||||
}
|
||||
|
||||
if (symbol is FirTypeParameterSymbol) {
|
||||
for (part in typeRef.qualifier) {
|
||||
if (part.typeArgumentList.typeArguments.isNotEmpty()) {
|
||||
return ConeErrorType(
|
||||
ConeUnexpectedTypeArgumentsError("Type arguments not allowed", part.typeArgumentList.source),
|
||||
typeArguments = resultingArguments
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return symbol.constructType(
|
||||
allTypeArguments.toTypedArray(),
|
||||
resultingArguments,
|
||||
typeRef.isMarkedNullable,
|
||||
typeRef.annotations.computeTypeAttributes(session)
|
||||
).also {
|
||||
|
||||
Reference in New Issue
Block a user