[FIR] Introduce FirDiagnostic in FIR instead of errorReason
This commit is contained in:
@@ -758,7 +758,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
|
||||
private fun FlowContent.generate(typeRef: FirTypeRef) {
|
||||
when (typeRef) {
|
||||
is FirErrorTypeRef -> error { +typeRef.reason }
|
||||
is FirErrorTypeRef -> error { +typeRef.diagnostic.reason }
|
||||
is FirResolvedTypeRef -> generate(typeRef.type)
|
||||
is FirImplicitTypeRef -> unresolved { keyword("<implicit>") }
|
||||
is FirUserTypeRef -> unresolved {
|
||||
@@ -956,7 +956,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
is FirErrorNamedReference -> {
|
||||
error {
|
||||
title = reference.errorReason
|
||||
title = reference.diagnostic.reason
|
||||
simpleName(reference.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,7 +969,7 @@ class Fir2IrVisitor(
|
||||
IrErrorExpressionImpl(
|
||||
startOffset, endOffset,
|
||||
errorExpression.typeRef.toIrType(session, declarationStorage),
|
||||
errorExpression.reason
|
||||
errorExpression.diagnostic.reason
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -260,7 +261,7 @@ private fun JavaAnnotationArgument.toFirExpression(
|
||||
null
|
||||
}
|
||||
this.calleeReference = calleeReference
|
||||
?: FirErrorNamedReferenceImpl(null, "Strange Java enum value: $classId.$entryName")
|
||||
?: FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Strange Java enum value: $classId.$entryName"))
|
||||
}
|
||||
}
|
||||
is JavaClassObjectAnnotationArgument -> FirGetClassCallImpl(null).apply {
|
||||
@@ -270,7 +271,7 @@ private fun JavaAnnotationArgument.toFirExpression(
|
||||
)
|
||||
}
|
||||
is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack)
|
||||
else -> FirErrorExpressionImpl(null, "Unknown JavaAnnotationArgument: ${this::class.java}")
|
||||
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unknown JavaAnnotationArgument: ${this::class.java}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +305,7 @@ internal fun Any?.createConstant(session: FirSession): FirExpression {
|
||||
is BooleanArray -> toList().createArrayOfCall(session, IrConstKind.Boolean)
|
||||
null -> FirConstExpressionImpl(null, IrConstKind.Null, null)
|
||||
|
||||
else -> FirErrorExpressionImpl(null, "Unknown value in JavaLiteralAnnotationArgument: $this")
|
||||
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unknown value in JavaLiteralAnnotationArgument: $this"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
|
||||
import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -174,7 +175,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
FirResolvedTypeRefImpl(
|
||||
null, it.constructType(emptyList(), isNullable = false)
|
||||
)
|
||||
} ?: FirErrorTypeRefImpl(null, "Symbol not found for $classId")
|
||||
} ?: FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Symbol not found for $classId"))
|
||||
|
||||
}
|
||||
|
||||
@@ -226,7 +227,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
else -> {
|
||||
FirErrorNamedReferenceImpl(
|
||||
null,
|
||||
errorReason = "Strange deserialized enum value: ${this@toEnumEntryReferenceExpression}.$name"
|
||||
FirSimpleDiagnostic("Strange deserialized enum value: ${this@toEnumEntryReferenceExpression}.$name")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+10
-9
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.builder.generateComponentFunctions
|
||||
import org.jetbrains.kotlin.fir.builder.generateCopyFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
||||
@@ -664,7 +665,7 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val delegatedSelfTypeRef =
|
||||
if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl(null, "Constructor in object")
|
||||
if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Constructor in object"))
|
||||
else classWrapper.delegatedSelfTypeRef
|
||||
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply {
|
||||
@@ -714,8 +715,8 @@ class DeclarationsConverter(
|
||||
val isThis = (isImplicit && classWrapper.hasPrimaryConstructor) || thisKeywordPresent
|
||||
val delegatedType =
|
||||
if (classWrapper.isObjectLiteral() || classWrapper.isInterface()) when {
|
||||
isThis -> FirErrorTypeRefImpl(null, "Constructor in object")
|
||||
else -> FirErrorTypeRefImpl(null, "No super type")
|
||||
isThis -> FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Constructor in object"))
|
||||
else -> FirErrorTypeRefImpl(null, FirSimpleDiagnostic("No super type"))
|
||||
}
|
||||
else when {
|
||||
isThis -> classWrapper.delegatedSelfTypeRef
|
||||
@@ -869,7 +870,7 @@ class DeclarationsConverter(
|
||||
private fun convertDestructingDeclaration(destructingDeclaration: LighterASTNode): DestructuringDeclaration {
|
||||
var isVar = false
|
||||
val entries = mutableListOf<FirVariable<*>>()
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "Destructuring declaration without initializer")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Destructuring declaration without initializer"))
|
||||
destructingDeclaration.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
VAR_KEYWORD -> isVar = true
|
||||
@@ -1165,7 +1166,7 @@ class DeclarationsConverter(
|
||||
*/
|
||||
private fun convertExplicitDelegation(explicitDelegation: LighterASTNode): FirDelegatedTypeRef {
|
||||
lateinit var firTypeRef: FirTypeRef
|
||||
var firExpression: FirExpression? = FirErrorExpressionImpl(null, "Should have delegate")
|
||||
var firExpression: FirExpression? = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Should have delegate"))
|
||||
explicitDelegation.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
TYPE_REFERENCE -> firTypeRef = convertType(it)
|
||||
@@ -1255,10 +1256,10 @@ class DeclarationsConverter(
|
||||
*/
|
||||
fun convertType(type: LighterASTNode): FirTypeRef {
|
||||
if (type.asText.isEmpty()) {
|
||||
return FirErrorTypeRefImpl(null, "Unwrapped type is null")
|
||||
return FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null"))
|
||||
}
|
||||
var typeModifiers = TypeModifier() //TODO what with suspend?
|
||||
var firType: FirTypeRef = FirErrorTypeRefImpl(null, "Incomplete code")
|
||||
var firType: FirTypeRef = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete code"))
|
||||
var afterLPar = false
|
||||
type.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -1269,7 +1270,7 @@ class DeclarationsConverter(
|
||||
NULLABLE_TYPE -> firType = convertNullableType(it)
|
||||
FUNCTION_TYPE -> firType = convertFunctionType(it)
|
||||
DYNAMIC_TYPE -> firType = FirDynamicTypeRefImpl(null, false)
|
||||
TokenType.ERROR_ELEMENT -> firType = FirErrorTypeRefImpl(null, "Unwrapped type is null")
|
||||
TokenType.ERROR_ELEMENT -> firType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1324,7 +1325,7 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
if (identifier == null)
|
||||
return FirErrorTypeRefImpl(null, "Incomplete user type")
|
||||
return FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete user type"))
|
||||
|
||||
val qualifier = FirQualifierPartImpl(
|
||||
identifier.nameAsSafeName()
|
||||
|
||||
+21
-20
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
@@ -56,7 +57,7 @@ class ExpressionsConverter(
|
||||
) : BaseConverter(session, tree, context) {
|
||||
|
||||
inline fun <reified R : FirElement> getAsFirExpression(expression: LighterASTNode?, errorReason: String = ""): R {
|
||||
return expression?.let { convertExpression(it, errorReason) } as? R ?: (FirErrorExpressionImpl(null, errorReason) as R)
|
||||
return expression?.let { convertExpression(it, errorReason) } as? R ?: (FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason)) as R)
|
||||
}
|
||||
|
||||
/***** EXPRESSIONS *****/
|
||||
@@ -104,7 +105,7 @@ class ExpressionsConverter(
|
||||
|
||||
OBJECT_LITERAL -> declarationsConverter.convertObjectLiteral(expression)
|
||||
FUN -> declarationsConverter.convertFunctionDeclaration(expression)
|
||||
else -> FirErrorExpressionImpl(null, errorReason)
|
||||
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ class ExpressionsConverter(
|
||||
FirLabelImpl(null, it.asString())
|
||||
}
|
||||
val bodyExpression = block?.let { declarationsConverter.convertBlockExpression(it) }
|
||||
?: FirErrorExpressionImpl(null, "Lambda has no body")
|
||||
?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Lambda has no body"))
|
||||
body = if (bodyExpression is FirBlockImpl) {
|
||||
if (bodyExpression.statements.isEmpty()) {
|
||||
bodyExpression.statements.add(FirUnitExpression(null))
|
||||
@@ -185,7 +186,7 @@ class ExpressionsConverter(
|
||||
var isLeftArgument = true
|
||||
lateinit var operationTokenName: String
|
||||
var leftArgNode: LighterASTNode? = null
|
||||
var rightArgAsFir: FirExpression = FirErrorExpressionImpl(null, "No right operand")
|
||||
var rightArgAsFir: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No right operand"))
|
||||
binaryExpression.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
OPERATION_REFERENCE -> {
|
||||
@@ -249,7 +250,7 @@ class ExpressionsConverter(
|
||||
toFirOperation: String.() -> FirOperation
|
||||
): FirTypeOperatorCall {
|
||||
lateinit var operationTokenName: String
|
||||
var leftArgAsFir: FirExpression = FirErrorExpressionImpl(null, "No left operand")
|
||||
var leftArgAsFir: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No left operand"))
|
||||
lateinit var firType: FirTypeRef
|
||||
binaryExpression.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -285,7 +286,7 @@ class ExpressionsConverter(
|
||||
context.firLabels.removeLast()
|
||||
//println("Unused label: ${labeledExpression.getAsString()}")
|
||||
}
|
||||
return firExpression ?: FirErrorExpressionImpl(null, "Empty label")
|
||||
return firExpression ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Empty label"))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +348,7 @@ class ExpressionsConverter(
|
||||
|
||||
return (firExpression as? FirAbstractAnnotatedElement)?.apply {
|
||||
annotations += firAnnotationList
|
||||
} ?: FirErrorExpressionImpl(null, "Strange annotated expression: ${firExpression?.render()}")
|
||||
} ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Strange annotated expression: ${firExpression?.render()}"))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +356,7 @@ class ExpressionsConverter(
|
||||
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitClassLiteralExpression
|
||||
*/
|
||||
private fun convertClassLiteralExpression(classLiteralExpression: LighterASTNode): FirExpression {
|
||||
var firReceiverExpression: FirExpression = FirErrorExpressionImpl(null, "No receiver in class literal")
|
||||
var firReceiverExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No receiver in class literal"))
|
||||
classLiteralExpression.forEachChildren {
|
||||
if (it.isExpression()) firReceiverExpression = getAsFirExpression(it, "No receiver in class literal")
|
||||
}
|
||||
@@ -399,7 +400,7 @@ class ExpressionsConverter(
|
||||
private fun convertQualifiedExpression(dotQualifiedExpression: LighterASTNode): FirExpression {
|
||||
var isSelector = false
|
||||
var isSafe = false
|
||||
var firSelector: FirExpression = FirErrorExpressionImpl(null, "Qualified expression without selector") //after dot
|
||||
var firSelector: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Qualified expression without selector")) //after dot
|
||||
var firReceiver: FirExpression? = null //before dot
|
||||
dotQualifiedExpression.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -449,7 +450,7 @@ class ExpressionsConverter(
|
||||
arguments += additionalArgument!!
|
||||
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null)
|
||||
}
|
||||
else -> FirErrorNamedReferenceImpl(null, "Call has no callee")
|
||||
else -> FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Call has no callee"))
|
||||
}
|
||||
|
||||
context.firFunctionCalls += this
|
||||
@@ -467,7 +468,7 @@ class ExpressionsConverter(
|
||||
}
|
||||
|
||||
private fun LighterASTNode?.convertShortOrLongStringTemplate(errorReason: String): FirExpression {
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, errorReason)
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason))
|
||||
this?.forEachChildren(LONG_TEMPLATE_ENTRY_START, LONG_TEMPLATE_ENTRY_END) {
|
||||
firExpression = getAsFirExpression(it, errorReason)
|
||||
}
|
||||
@@ -563,7 +564,7 @@ class ExpressionsConverter(
|
||||
}
|
||||
|
||||
private fun convertWhenConditionExpression(whenCondition: LighterASTNode): FirExpression {
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "No expression in condition with expression")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No expression in condition with expression"))
|
||||
whenCondition.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
else -> if (it.isExpression()) firExpression = getAsFirExpression(it, "No expression in condition with expression")
|
||||
@@ -577,7 +578,7 @@ class ExpressionsConverter(
|
||||
|
||||
private fun convertWhenConditionInRange(whenCondition: LighterASTNode): FirExpression {
|
||||
var isNegate = false
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "No range in condition with range")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No range in condition with range"))
|
||||
whenCondition.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
NOT_IN -> isNegate = true
|
||||
@@ -611,7 +612,7 @@ class ExpressionsConverter(
|
||||
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitArrayAccessExpression
|
||||
*/
|
||||
private fun convertArrayAccessExpression(arrayAccess: LighterASTNode): FirFunctionCall {
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "No array expression")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No array expression"))
|
||||
val indices: MutableList<FirExpression> = mutableListOf()
|
||||
arrayAccess.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -669,7 +670,7 @@ class ExpressionsConverter(
|
||||
*/
|
||||
private fun convertDoWhile(doWhileLoop: LighterASTNode): FirElement {
|
||||
var block: LighterASTNode? = null
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, "No condition in do-while loop")
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No condition in do-while loop"))
|
||||
doWhileLoop.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
BODY -> block = it
|
||||
@@ -686,7 +687,7 @@ class ExpressionsConverter(
|
||||
*/
|
||||
private fun convertWhile(whileLoop: LighterASTNode): FirElement {
|
||||
var block: LighterASTNode? = null
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, "No condition in while loop")
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No condition in while loop"))
|
||||
whileLoop.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
BODY -> block = it
|
||||
@@ -703,7 +704,7 @@ class ExpressionsConverter(
|
||||
*/
|
||||
private fun convertFor(forLoop: LighterASTNode): FirElement {
|
||||
var parameter: ValueParameter? = null
|
||||
var rangeExpression: FirExpression = FirErrorExpressionImpl(null, "No range in for loop")
|
||||
var rangeExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No range in for loop"))
|
||||
var blockNode: LighterASTNode? = null
|
||||
forLoop.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -846,7 +847,7 @@ class ExpressionsConverter(
|
||||
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitIfExpression
|
||||
*/
|
||||
private fun convertIfExpression(ifExpression: LighterASTNode): FirExpression {
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, "If statement should have condition")
|
||||
var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("If statement should have condition"))
|
||||
var thenBlock: LighterASTNode? = null
|
||||
var elseBlock: LighterASTNode? = null
|
||||
ifExpression.forEachChildren {
|
||||
@@ -908,7 +909,7 @@ class ExpressionsConverter(
|
||||
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitThrowExpression
|
||||
*/
|
||||
private fun convertThrow(throwExpression: LighterASTNode): FirExpression {
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "Nothing to throw")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Nothing to throw"))
|
||||
throwExpression.forEachChildren {
|
||||
if (it.isExpression()) firExpression = getAsFirExpression(it, "Nothing to throw")
|
||||
}
|
||||
@@ -963,7 +964,7 @@ class ExpressionsConverter(
|
||||
private fun convertValueArgument(valueArgument: LighterASTNode): FirExpression {
|
||||
var identifier: String? = null
|
||||
var isSpread = false
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, "Argument is absent")
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Argument is absent"))
|
||||
valueArgument.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
VALUE_ARGUMENT_NAME -> identifier = it.asText
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference
|
||||
@@ -35,7 +36,7 @@ class ValueParameter(
|
||||
val name = this.firValueParameter.name
|
||||
var type = this.firValueParameter.returnTypeRef
|
||||
if (type is FirImplicitTypeRef) {
|
||||
type = FirErrorTypeRefImpl(null, "Incomplete code")
|
||||
type = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete code"))
|
||||
}
|
||||
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply {
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.lightTree.fir
|
||||
import org.jetbrains.kotlin.fir.FirWhenSubject
|
||||
import org.jetbrains.kotlin.fir.builder.generateContainsOperation
|
||||
import org.jetbrains.kotlin.fir.builder.generateLazyLogicalOperation
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirOperatorCallImpl
|
||||
@@ -51,7 +52,7 @@ data class WhenEntry(
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
FirErrorExpressionImpl(null, "Unsupported when condition: ${this.javaClass}")
|
||||
FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unsupported when condition: ${this.javaClass}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +60,7 @@ data class WhenEntry(
|
||||
fun toFirWhenConditionWithoutSubject(): FirExpression {
|
||||
return when (val condition = conditions.first()) {
|
||||
is FirOperatorCallImpl -> condition.arguments.first()
|
||||
else -> FirErrorExpressionImpl(null, "No expression in condition with expression")
|
||||
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("No expression in condition with expression"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
@@ -110,7 +111,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
FirErrorFunctionImpl(
|
||||
source,
|
||||
this@BaseFirBuilder.session,
|
||||
"Cannot bind unlabeled return to a function",
|
||||
FirSimpleDiagnostic("Cannot bind unlabeled return to a function"),
|
||||
FirErrorFunctionSymbol()
|
||||
)
|
||||
)
|
||||
@@ -136,7 +137,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
FirErrorFunctionImpl(
|
||||
source,
|
||||
this@BaseFirBuilder.session,
|
||||
"Cannot bind label $labelName to a function",
|
||||
FirSimpleDiagnostic("Cannot bind label $labelName to a function"),
|
||||
FirErrorFunctionSymbol()
|
||||
)
|
||||
)
|
||||
@@ -238,7 +239,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
expression.getSourceOrNull(), IrConstKind.Int, convertedText.toInt(), "Incorrect int: $text"
|
||||
)
|
||||
} else {
|
||||
FirErrorExpressionImpl(expression.getSourceOrNull(), reason = "Incorrect constant expression: $text")
|
||||
FirErrorExpressionImpl(expression.getSourceOrNull(), diagnostic = FirSimpleDiagnostic("Incorrect constant expression: $text"))
|
||||
}
|
||||
FLOAT_CONSTANT ->
|
||||
if (convertedText is Float) {
|
||||
@@ -290,7 +291,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
else -> {
|
||||
hasExpressions = true
|
||||
FirErrorExpressionImpl(
|
||||
entry.getSourceOrNull(), "Incorrect template entry: ${entry.asText}"
|
||||
entry.getSourceOrNull(), FirSimpleDiagnostic("Incorrect template entry: ${entry.asText}")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -343,7 +344,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
convert: T.() -> FirExpression
|
||||
): FirExpression {
|
||||
if (argument == null) {
|
||||
return FirErrorExpressionImpl(argument, "Inc/dec without operand")
|
||||
return FirErrorExpressionImpl(argument, FirSimpleDiagnostic("Inc/dec without operand"))
|
||||
}
|
||||
val source = baseExpression?.toFirSourceElement()
|
||||
return FirBlockImpl(source).apply {
|
||||
@@ -410,7 +411,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
firMemberAccess.calleeReference
|
||||
} else {
|
||||
FirErrorNamedReferenceImpl(
|
||||
left.getSourceOrNull(), "Unsupported qualified LValue: ${left.asText}"
|
||||
left.getSourceOrNull(), FirSimpleDiagnostic("Unsupported qualified LValue: ${left.asText}")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -419,7 +420,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
}
|
||||
}
|
||||
}
|
||||
return FirErrorNamedReferenceImpl(left.getSourceOrNull(), "Unsupported LValue: $tokenType")
|
||||
return FirErrorNamedReferenceImpl(left.getSourceOrNull(), FirSimpleDiagnostic("Unsupported LValue: $tokenType"))
|
||||
}
|
||||
|
||||
fun T?.generateAssignment(
|
||||
@@ -468,7 +469,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
statements += generateTemporaryVariable(
|
||||
this@BaseFirBuilder.session, this@generateAssignment.getSourceOrNull(), name,
|
||||
this@generateAssignment?.convert()
|
||||
?: FirErrorExpressionImpl(this.getSourceOrNull(), "No LValue in assignment")
|
||||
?: FirErrorExpressionImpl(this.getSourceOrNull(), FirSimpleDiagnostic("No LValue in assignment"))
|
||||
)
|
||||
statements += FirVariableAssignmentImpl(source, false, value, operation).apply {
|
||||
lValue = FirSimpleNamedReference(this.getSourceOrNull(), name, null)
|
||||
@@ -479,7 +480,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
if (operation in FirOperation.ASSIGNMENTS && operation != FirOperation.ASSIGN) {
|
||||
return FirOperatorCallImpl(source, operation).apply {
|
||||
// TODO: take good psi
|
||||
arguments += this@generateAssignment?.convert() ?: FirErrorExpressionImpl(null, "Unsupported left value of assignment: ${source?.psi?.text}")
|
||||
arguments += this@generateAssignment?.convert() ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unsupported left value of assignment: ${source?.psi?.text}"))
|
||||
arguments += value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
@@ -200,7 +201,7 @@ internal fun KtWhenCondition.toFirWhenCondition(
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
FirErrorExpressionImpl(this.toFirSourceElement(), "Unsupported when condition: ${this.javaClass}")
|
||||
FirErrorExpressionImpl(this.toFirSourceElement(), FirSimpleDiagnostic("Unsupported when condition: ${this.javaClass}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
@@ -105,21 +106,21 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
convertSafe() ?: implicitUnitType
|
||||
|
||||
private fun KtTypeReference?.toFirOrErrorType(): FirTypeRef =
|
||||
convertSafe() ?: FirErrorTypeRefImpl(this?.toFirSourceElement(), if (this == null) "Incomplete code" else "Conversion failed")
|
||||
convertSafe() ?: FirErrorTypeRefImpl(this?.toFirSourceElement(), FirSimpleDiagnostic(if (this == null) "Incomplete code" else "Conversion failed"))
|
||||
|
||||
// Here we accept lambda as receiver to prevent expression calculation in stub mode
|
||||
private fun (() -> KtExpression?).toFirExpression(errorReason: String): FirExpression =
|
||||
if (stubMode) FirExpressionStub(null)
|
||||
else with(this()) {
|
||||
convertSafe<FirExpression>() ?: FirErrorExpressionImpl(this?.toFirSourceElement(), errorReason)
|
||||
convertSafe<FirExpression>() ?: FirErrorExpressionImpl(this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason))
|
||||
}
|
||||
|
||||
private fun KtExpression?.toFirExpression(errorReason: String): FirExpression =
|
||||
if (stubMode) FirExpressionStub(null)
|
||||
else convertSafe<FirExpression>() ?: FirErrorExpressionImpl(this?.toFirSourceElement(), errorReason)
|
||||
else convertSafe<FirExpression>() ?: FirErrorExpressionImpl(this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason))
|
||||
|
||||
private fun KtExpression.toFirStatement(errorReason: String): FirStatement =
|
||||
convertSafe() ?: FirErrorExpressionImpl(this.toFirSourceElement(), errorReason)
|
||||
convertSafe() ?: FirErrorExpressionImpl(this.toFirSourceElement(), FirSimpleDiagnostic(errorReason))
|
||||
|
||||
private fun KtExpression.toFirStatement(): FirStatement =
|
||||
convert()
|
||||
@@ -130,7 +131,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
return when (this) {
|
||||
is KtSecondaryConstructor -> toFirConstructor(
|
||||
delegatedSuperType,
|
||||
delegatedSelfType ?: FirErrorTypeRefImpl(this.toFirSourceElement(), "Constructor in object"),
|
||||
delegatedSelfType ?: FirErrorTypeRefImpl(this.toFirSourceElement(), FirSimpleDiagnostic("Constructor in object")),
|
||||
owner,
|
||||
hasPrimaryConstructor
|
||||
)
|
||||
@@ -165,7 +166,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
|
||||
private fun ValueArgument?.toFirExpression(): FirExpression {
|
||||
this ?: return FirErrorExpressionImpl((this as? KtElement)?.toFirSourceElement(), "No argument given")
|
||||
this ?: return FirErrorExpressionImpl((this as? KtElement)?.toFirSourceElement(), FirSimpleDiagnostic("No argument given"))
|
||||
val name = this.getArgumentName()?.asName
|
||||
val expression = this.getArgumentExpression()
|
||||
val firExpression = when (expression) {
|
||||
@@ -718,7 +719,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
val source = this.toFirSourceElement()
|
||||
val delegatedType = when {
|
||||
isThis -> delegatedSelfTypeRef
|
||||
else -> delegatedSuperTypeRef ?: FirErrorTypeRefImpl(source, "No super type")
|
||||
else -> delegatedSuperTypeRef ?: FirErrorTypeRefImpl(source, FirSimpleDiagnostic("No super type"))
|
||||
}
|
||||
return FirDelegatedConstructorCallImpl(
|
||||
source,
|
||||
@@ -837,7 +838,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
|
||||
userType
|
||||
} else {
|
||||
FirErrorTypeRefImpl(source, "Incomplete user type")
|
||||
FirErrorTypeRefImpl(source, FirSimpleDiagnostic("Incomplete user type"))
|
||||
}
|
||||
}
|
||||
is KtFunctionType -> {
|
||||
@@ -856,7 +857,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
functionType
|
||||
}
|
||||
null -> FirErrorTypeRefImpl(source, "Unwrapped type is null")
|
||||
null -> FirErrorTypeRefImpl(source, FirSimpleDiagnostic("Unwrapped type is null"))
|
||||
else -> throw AssertionError("Unexpected type element: ${unwrappedElement.text}")
|
||||
}
|
||||
|
||||
@@ -1230,7 +1231,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
calleeExpression.toFirSourceElement(), calleeExpression.getReferencedNameAsName(), null
|
||||
)
|
||||
null -> FirErrorNamedReferenceImpl(
|
||||
null, "Call has no callee"
|
||||
null, FirSimpleDiagnostic("Call has no callee")
|
||||
)
|
||||
else -> {
|
||||
arguments += calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||
@@ -1263,7 +1264,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
|
||||
override fun visitQualifiedExpression(expression: KtQualifiedExpression, data: Unit): FirElement {
|
||||
val selector = expression.selectorExpression
|
||||
?: return FirErrorExpressionImpl(expression.toFirSourceElement(), "Qualified expression without selector")
|
||||
?: return FirErrorExpressionImpl(expression.toFirSourceElement(), FirSimpleDiagnostic("Qualified expression without selector"))
|
||||
val firSelector = selector.toFirExpression("Incorrect selector expression")
|
||||
if (firSelector is FirModifiableQualifiedAccess) {
|
||||
firSelector.safe = expression is KtSafeQualifiedExpression
|
||||
@@ -1287,7 +1288,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
|
||||
override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, data: Unit): FirElement {
|
||||
return expression.expression?.accept(this, data) ?: FirErrorExpressionImpl(expression.toFirSourceElement(), "Empty parentheses")
|
||||
return expression.expression?.accept(this, data) ?: FirErrorExpressionImpl(expression.toFirSourceElement(), FirSimpleDiagnostic("Empty parentheses"))
|
||||
}
|
||||
|
||||
override fun visitLabeledExpression(expression: KtLabeledExpression, data: Unit): FirElement {
|
||||
@@ -1297,7 +1298,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
if (labelName != null) {
|
||||
context.firLabels += FirLabelImpl(source, labelName)
|
||||
}
|
||||
val result = expression.baseExpression?.accept(this, data) ?: FirErrorExpressionImpl(source, "Empty label")
|
||||
val result = expression.baseExpression?.accept(this, data) ?: FirErrorExpressionImpl(source, FirSimpleDiagnostic("Empty label"))
|
||||
if (size != context.firLabels.size) {
|
||||
context.firLabels.removeLast()
|
||||
println("Unused label: ${expression.text}")
|
||||
@@ -1308,7 +1309,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
override fun visitAnnotatedExpression(expression: KtAnnotatedExpression, data: Unit): FirElement {
|
||||
val rawResult = expression.baseExpression?.accept(this, data)
|
||||
val result = rawResult as? FirAbstractAnnotatedElement
|
||||
?: FirErrorExpressionImpl(expression.toFirSourceElement(), "Strange annotated expression: ${rawResult?.render()}")
|
||||
?: FirErrorExpressionImpl(expression.toFirSourceElement(), FirSimpleDiagnostic("Strange annotated expression: ${rawResult?.render()}"))
|
||||
expression.extractAnnotationsTo(result)
|
||||
return result
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
|
||||
val calleeReference = qualifiedAccess.calleeReference
|
||||
if (calleeReference is FirErrorNamedReference) {
|
||||
errorReferences++
|
||||
println(calleeReference.errorReason)
|
||||
println(calleeReference.diagnostic.reason)
|
||||
} else {
|
||||
normalReferences++
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl
|
||||
@@ -365,12 +366,12 @@ class FirCallResolver(
|
||||
val source = namedReference.source
|
||||
return when {
|
||||
candidates.isEmpty() -> FirErrorNamedReferenceImpl(
|
||||
source, "Unresolved name: $name"
|
||||
source, FirSimpleDiagnostic("Unresolved name: $name")
|
||||
)
|
||||
applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> {
|
||||
FirErrorNamedReferenceImpl(
|
||||
source,
|
||||
"Inapplicable($applicability): ${candidates.map { describeSymbol(it.symbol) }}"
|
||||
FirSimpleDiagnostic("Inapplicable($applicability): ${candidates.map { describeSymbol(it.symbol) }}")
|
||||
)
|
||||
}
|
||||
candidates.size == 1 -> {
|
||||
@@ -387,7 +388,7 @@ class FirCallResolver(
|
||||
}
|
||||
}
|
||||
else -> FirErrorNamedReferenceImpl(
|
||||
source, "Ambiguity: $name, ${candidates.map { describeSymbol(it.symbol) }}"
|
||||
source, FirSimpleDiagnostic("Ambiguity: $name, ${candidates.map { describeSymbol(it.symbol) }}")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.deserialization
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
@@ -96,7 +97,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
FirResolvedTypeRefImpl(
|
||||
null, it.constructType(emptyList(), isNullable = false)
|
||||
)
|
||||
} ?: FirErrorTypeRefImpl(null, "Symbol not found for $classId")
|
||||
} ?: FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Symbol not found for $classId"))
|
||||
).apply {
|
||||
this.arguments += arguments
|
||||
}
|
||||
@@ -137,7 +138,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
FirResolvedNamedReferenceImpl(null, entryName, it)
|
||||
} ?: FirErrorNamedReferenceImpl(
|
||||
null,
|
||||
errorReason = "Strange deserialized enum value: $classId.$entryName"
|
||||
FirSimpleDiagnostic("Strange deserialized enum value: $classId.$entryName")
|
||||
)
|
||||
}
|
||||
// ARRAY -> {
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.componentArrayAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
@@ -295,7 +296,7 @@ fun <T : FirResolvable> BodyResolveComponents.typeFromCallee(access: T): FirReso
|
||||
|
||||
return when (val newCallee = access.calleeReference) {
|
||||
is FirErrorNamedReference ->
|
||||
FirErrorTypeRefImpl(access.source, newCallee.errorReason)
|
||||
FirErrorTypeRefImpl(access.source, newCallee.diagnostic)
|
||||
is FirNamedReferenceWithCandidate -> {
|
||||
typeFromSymbol(newCallee.candidateSymbol, makeNullable)
|
||||
}
|
||||
@@ -329,7 +330,7 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<
|
||||
if (fir is FirEnumEntry) {
|
||||
(fir.superTypeRefs.firstOrNull() as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(
|
||||
null,
|
||||
"no enum item supertype"
|
||||
FirSimpleDiagnostic("no enum item supertype")
|
||||
)
|
||||
} else
|
||||
FirResolvedTypeRefImpl(
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirCallResolver
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
@@ -84,7 +85,7 @@ class PostponedArgumentsAnalyzer(
|
||||
candidate == null || applicability < CandidateApplicability.SYNTHETIC_RESOLVED ->
|
||||
FirErrorNamedReferenceImpl(
|
||||
callableReferenceAccess.source,
|
||||
"Unresolved reference: ${callableReferenceAccess.calleeReference.name}"
|
||||
FirSimpleDiagnostic("Unresolved reference: ${callableReferenceAccess.calleeReference.name}")
|
||||
)
|
||||
else -> FirNamedReferenceWithCandidate(callableReferenceAccess.source, callableReferenceAccess.calleeReference.name, candidate)
|
||||
}
|
||||
|
||||
+1
-3
@@ -104,9 +104,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver {
|
||||
is FirUserTypeRef -> {
|
||||
resolveUserType(typeRef, resolveToSymbol(typeRef, scope), scope)
|
||||
}
|
||||
is FirErrorTypeRef -> {
|
||||
ConeKotlinErrorType(typeRef.reason)
|
||||
}
|
||||
is FirErrorTypeRef -> typeRef.type
|
||||
is FirFunctionTypeRef -> {
|
||||
createFunctionalType(typeRef)
|
||||
}
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
@@ -164,7 +165,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
val coneType = (superTypeRef as FirResolvedTypeRef).type
|
||||
if (coneType is ConeTypeParameterType) {
|
||||
resultingTypeRefs.add(
|
||||
FirErrorTypeRefImpl(superTypeRef.source, "Type parameter cannot be a super-type: ${coneType.render()}")
|
||||
FirErrorTypeRefImpl(superTypeRef.source, FirSimpleDiagnostic("Type parameter cannot be a super-type: ${coneType.render()}"))
|
||||
)
|
||||
continue
|
||||
}
|
||||
@@ -173,7 +174,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
|
||||
if (superTypeClassId.outerClasses().any { it.areSupertypesComputing() }) {
|
||||
resultingTypeRefs.add(
|
||||
FirErrorTypeRefImpl(superTypeRef.source, "Recursion detected: ${superTypeRef.render()}")
|
||||
FirErrorTypeRefImpl(superTypeRef.source, FirSimpleDiagnostic("Recursion detected: ${superTypeRef.render()}"))
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
+4
-3
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
@@ -31,7 +32,7 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc
|
||||
if (declaration.returnTypeRef is FirComputingImplicitTypeRef) {
|
||||
declaration.transformReturnTypeRef(
|
||||
TransformImplicitType,
|
||||
FirErrorTypeRefImpl(null, "cycle")
|
||||
FirErrorTypeRefImpl(null, FirSimpleDiagnostic("cycle"))
|
||||
)
|
||||
return declaration.returnTypeRef as FirResolvedTypeRef
|
||||
}
|
||||
@@ -46,7 +47,7 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc
|
||||
TransformImplicitType,
|
||||
FirErrorTypeRefImpl(
|
||||
null,
|
||||
"Unsupported: implicit VP type"
|
||||
FirSimpleDiagnostic("Unsupported: implicit VP type")
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -68,7 +69,7 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc
|
||||
}.mapTo(mutableListOf()) { provider.getFirClassifierByFqName(it) }
|
||||
|
||||
if (file == null || outerClasses.any { it == null }) {
|
||||
return FirErrorTypeRefImpl(null, "Cannot calculate return type (local class/object?)")
|
||||
return FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Cannot calculate return type (local class/object?)"))
|
||||
}
|
||||
|
||||
declaration.transformReturnTypeRef(
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirTargetElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock
|
||||
@@ -71,7 +72,7 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran
|
||||
whenExpression = syntheticCallGenerator.generateCalleeForWhenExpression(whenExpression) ?: run {
|
||||
whenExpression = whenExpression.transformSingle(whenExhaustivenessTransformer, null)
|
||||
dataFlowAnalyzer.exitWhenExpression(whenExpression)
|
||||
whenExpression.resultType = FirErrorTypeRefImpl(null, "")
|
||||
whenExpression.resultType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic(""))
|
||||
return@with whenExpression.compose()
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran
|
||||
val expectedTypeRef = data as FirTypeRef?
|
||||
callCompleter.completeCall(it, expectedTypeRef)
|
||||
} ?: run {
|
||||
tryExpression.resultType = FirErrorTypeRefImpl(null, "")
|
||||
tryExpression.resultType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic(""))
|
||||
tryExpression
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.copy
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue
|
||||
@@ -336,7 +337,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
||||
val bodyExpectedType = returnTypeRefFromResolvedAtom ?: data
|
||||
af = transformFunction(af, bodyExpectedType).single as FirAnonymousFunction
|
||||
af = af.copy(
|
||||
returnTypeRef = af.body?.resultType ?: FirErrorTypeRefImpl(af.source, "No result type for lambda")
|
||||
returnTypeRef = af.body?.resultType ?: FirErrorTypeRefImpl(af.source, FirSimpleDiagnostic("No result type for lambda"))
|
||||
)
|
||||
af.replaceTypeRef(af.constructFunctionalTypeRef(session))
|
||||
af.compose()
|
||||
@@ -383,7 +384,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
||||
when (val resultType = initializer.resultType) {
|
||||
is FirImplicitTypeRef -> FirErrorTypeRefImpl(
|
||||
null,
|
||||
"No result type for initializer"
|
||||
FirSimpleDiagnostic("No result type for initializer")
|
||||
)
|
||||
else -> resultType
|
||||
}
|
||||
@@ -395,7 +396,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
||||
when (val resultType = variable.getter?.returnTypeRef) {
|
||||
is FirImplicitTypeRef -> FirErrorTypeRefImpl(
|
||||
null,
|
||||
"No result type for getter"
|
||||
FirSimpleDiagnostic("No result type for getter")
|
||||
)
|
||||
else -> resultType
|
||||
}
|
||||
@@ -403,7 +404,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
||||
}
|
||||
else -> {
|
||||
variable.transformReturnTypeRef(
|
||||
transformer, FirErrorTypeRefImpl(null, "Cannot infer variable type without initializer / getter / delegate")
|
||||
transformer, FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Cannot infer variable type without initializer / getter / delegate"))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||
import org.jetbrains.kotlin.fir.BuiltinTypes
|
||||
import org.jetbrains.kotlin.fir.FirCallResolver
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl
|
||||
@@ -55,7 +56,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
|
||||
override fun transformExpression(expression: FirExpression, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
if (expression.resultType is FirImplicitTypeRef && expression !is FirWrappedExpression) {
|
||||
val type = FirErrorTypeRefImpl(expression.source, "Type calculating for ${expression::class} is not supported")
|
||||
val type = FirErrorTypeRefImpl(expression.source, FirSimpleDiagnostic("Type calculating for ${expression::class} is not supported"))
|
||||
expression.resultType = type
|
||||
}
|
||||
return (expression.transformChildren(transformer, data) as FirStatement).compose()
|
||||
@@ -83,7 +84,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
} else {
|
||||
val superTypeRef = implicitReceiverStack.lastDispatchReceiver()
|
||||
?.boundSymbol?.phasedFir?.superTypeRefs?.firstOrNull()
|
||||
?: FirErrorTypeRefImpl(qualifiedAccessExpression.source, "No super type")
|
||||
?: FirErrorTypeRefImpl(qualifiedAccessExpression.source, FirSimpleDiagnostic("No super type"))
|
||||
qualifiedAccessExpression.resultType = superTypeRef
|
||||
callee.replaceSuperTypeRef(superTypeRef)
|
||||
}
|
||||
@@ -171,7 +172,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
block.resultType = if (resultExpression == null) {
|
||||
FirImplicitUnitTypeRef(block.source)
|
||||
} else {
|
||||
(resultExpression.resultType as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(null, "No type for block")
|
||||
(resultExpression.resultType as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(null, FirSimpleDiagnostic("No type for block"))
|
||||
}
|
||||
dataFlowAnalyzer.exitBlock(block)
|
||||
return block.compose()
|
||||
@@ -228,13 +229,13 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
val assignment =
|
||||
FirVariableAssignmentImpl(operatorCall.source, false, resolvedOperatorCall, FirOperation.ASSIGN).apply {
|
||||
lValue = (leftArgument as? FirQualifiedAccess)?.calleeReference
|
||||
?: FirErrorNamedReferenceImpl(null, "Unresolved reference")
|
||||
?: FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Unresolved reference"))
|
||||
}
|
||||
assignment.transform(transformer, noExpectedType)
|
||||
}
|
||||
else -> FirErrorExpressionImpl(
|
||||
operatorCall.source,
|
||||
"Operator overload ambiguity. $assignmentOperatorName and $simpleOperatorName are compatible"
|
||||
FirSimpleDiagnostic("Operator overload ambiguity. $assignmentOperatorName and $simpleOperatorName are compatible")
|
||||
).compose()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
|
||||
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) {
|
||||
visitTypeRef(errorTypeRef)
|
||||
print("<ERROR TYPE REF: ${errorTypeRef.reason}>")
|
||||
print("<ERROR TYPE REF: ${errorTypeRef.diagnostic.reason}>")
|
||||
}
|
||||
|
||||
override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
|
||||
@@ -790,7 +790,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
symbol != null -> {
|
||||
print("R?C|${symbol.render()}|")
|
||||
}
|
||||
namedReference is FirErrorNamedReference -> print("<${namedReference.errorReason}>#")
|
||||
namedReference is FirErrorNamedReference -> print("<${namedReference.diagnostic.reason}>#")
|
||||
else -> print("${namedReference.name}#")
|
||||
}
|
||||
}
|
||||
@@ -1000,7 +1000,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
}
|
||||
|
||||
override fun visitErrorExpression(errorExpression: FirErrorExpression) {
|
||||
print("ERROR_EXPR(${errorExpression.reason})")
|
||||
print("ERROR_EXPR(${errorExpression.diagnostic.reason})")
|
||||
}
|
||||
|
||||
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) {
|
||||
|
||||
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.fir.declarations
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
@@ -20,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirErrorFunction : FirPureAbstractElement(), FirFunction<FirErrorFunction> {
|
||||
abstract class FirErrorFunction : FirPureAbstractElement(), FirFunction<FirErrorFunction>, FirDiagnosticHolder {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val session: FirSession
|
||||
abstract override val resolvePhase: FirResolvePhase
|
||||
@@ -31,7 +33,7 @@ abstract class FirErrorFunction : FirPureAbstractElement(), FirFunction<FirError
|
||||
abstract override val typeParameters: List<FirTypeParameter>
|
||||
abstract override val valueParameters: List<FirValueParameter>
|
||||
abstract override val body: FirBlock?
|
||||
abstract val reason: String
|
||||
abstract override val diagnostic: FirDiagnostic
|
||||
abstract override val symbol: FirErrorFunctionSymbol
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorFunction(this, data)
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
@@ -29,12 +30,12 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
class FirErrorFunctionImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val session: FirSession,
|
||||
override val reason: String,
|
||||
override val diagnostic: FirDiagnostic,
|
||||
override val symbol: FirErrorFunctionSymbol
|
||||
) : FirErrorFunction(), FirAbstractAnnotatedElement {
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, reason)
|
||||
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic)
|
||||
override val receiverTypeRef: FirTypeRef? get() = null
|
||||
override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference()
|
||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.diagnostics
|
||||
|
||||
abstract class FirDiagnostic {
|
||||
abstract val reason: String
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
interface FirDiagnosticHolder : FirElement {
|
||||
override val source: FirSourceElement?
|
||||
val diagnostic: FirDiagnostic
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDiagnosticHolder(this, data)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.diagnostics
|
||||
|
||||
class FirSimpleDiagnostic(override val reason: String) : FirDiagnostic()
|
||||
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.fir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
@@ -15,11 +17,11 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirErrorExpression : FirPureAbstractElement(), FirExpression {
|
||||
abstract class FirErrorExpression : FirPureAbstractElement(), FirExpression, FirDiagnosticHolder {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val typeRef: FirTypeRef
|
||||
abstract override val annotations: List<FirAnnotationCall>
|
||||
abstract val reason: String
|
||||
abstract override val diagnostic: FirDiagnostic
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorExpression(this, data)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirLabel
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirErrorLoop : FirPureAbstractElement(), FirLoop, FirDiagnosticHolder {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val annotations: List<FirAnnotationCall>
|
||||
abstract override val block: FirBlock
|
||||
abstract override val condition: FirExpression
|
||||
abstract override val label: FirLabel?
|
||||
abstract override val diagnostic: FirDiagnostic
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorLoop(this, data)
|
||||
|
||||
abstract override fun <D> transformBlock(transformer: FirTransformer<D>, data: D): FirErrorLoop
|
||||
|
||||
abstract override fun <D> transformCondition(transformer: FirTransformer<D>, data: D): FirErrorLoop
|
||||
|
||||
abstract override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirErrorLoop
|
||||
}
|
||||
@@ -6,9 +6,10 @@
|
||||
package org.jetbrains.kotlin.fir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorLoopImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
@@ -24,7 +25,7 @@ inline val FirAnnotationCall.classId: ClassId?
|
||||
get() = coneClassLikeType?.lookupTag?.classId
|
||||
|
||||
fun <T> FirConstExpressionImpl(source: FirSourceElement?, kind: IrConstKind<T>, value: T?, errorReason: String): FirExpression =
|
||||
value?.let { FirConstExpressionImpl(source, kind, it) } ?: FirErrorExpressionImpl(source, errorReason)
|
||||
value?.let { FirConstExpressionImpl(source, kind, it) } ?: FirErrorExpressionImpl(source, FirSimpleDiagnostic(errorReason))
|
||||
|
||||
inline val FirTypeOperatorCall.argument: FirExpression get() = arguments.first()
|
||||
|
||||
@@ -36,6 +37,9 @@ fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? {
|
||||
return toResolvedCallableReference()?.resolvedSymbol as FirCallableSymbol<*>?
|
||||
}
|
||||
|
||||
fun FirErrorLoop(source: FirSourceElement?, reason: String): FirErrorLoop = FirErrorLoop(source).apply {
|
||||
condition = FirErrorExpressionImpl(source, reason)
|
||||
fun FirErrorLoop(source: FirSourceElement?, reason: String): FirErrorLoop {
|
||||
val diagnostic = FirSimpleDiagnostic(reason)
|
||||
return FirErrorLoopImpl(source, diagnostic).apply {
|
||||
condition = FirErrorExpressionImpl(source, diagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.expressions.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
@@ -20,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
class FirErrorExpressionImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val reason: String
|
||||
override val diagnostic: FirDiagnostic
|
||||
) : FirErrorExpression(), FirAbstractAnnotatedElement {
|
||||
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
+11
-10
@@ -6,12 +6,12 @@
|
||||
package org.jetbrains.kotlin.fir.expressions.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirLabel
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
@@ -20,12 +20,13 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
class FirErrorLoop(
|
||||
override val source: FirSourceElement?
|
||||
) : FirPureAbstractElement(), FirLoop, FirAbstractAnnotatedElement {
|
||||
class FirErrorLoopImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val diagnostic: FirDiagnostic
|
||||
) : FirErrorLoop(), FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override var block: FirBlock = FirEmptyExpressionBlock()
|
||||
override var condition: FirExpression = FirErrorExpressionImpl(source, "error loop")
|
||||
override var condition: FirExpression = FirErrorExpressionImpl(source, diagnostic)
|
||||
override var label: FirLabel? = null
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
@@ -35,24 +36,24 @@ class FirErrorLoop(
|
||||
label?.accept(visitor, data)
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirErrorLoop {
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirErrorLoopImpl {
|
||||
transformBlock(transformer, data)
|
||||
transformCondition(transformer, data)
|
||||
transformOtherChildren(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformBlock(transformer: FirTransformer<D>, data: D): FirErrorLoop {
|
||||
override fun <D> transformBlock(transformer: FirTransformer<D>, data: D): FirErrorLoopImpl {
|
||||
block = block.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformCondition(transformer: FirTransformer<D>, data: D): FirErrorLoop {
|
||||
override fun <D> transformCondition(transformer: FirTransformer<D>, data: D): FirErrorLoopImpl {
|
||||
condition = condition.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirErrorLoop {
|
||||
override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirErrorLoopImpl {
|
||||
annotations.transformInplace(transformer, data)
|
||||
label = label?.transformSingle(transformer, data)
|
||||
return this
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.jetbrains.kotlin.fir.references
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
@@ -15,11 +17,11 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirErrorNamedReference : FirNamedReference() {
|
||||
abstract class FirErrorNamedReference : FirNamedReference(), FirDiagnosticHolder {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val name: Name
|
||||
abstract override val candidateSymbol: AbstractFirBasedSymbol<*>?
|
||||
abstract val errorReason: String
|
||||
abstract override val diagnostic: FirDiagnostic
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorNamedReference(this, data)
|
||||
}
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.references.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -18,9 +19,9 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
class FirErrorNamedReferenceImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val errorReason: String
|
||||
override val diagnostic: FirDiagnostic
|
||||
) : FirErrorNamedReference() {
|
||||
override val name: Name = Name.special("<$errorReason>")
|
||||
override val name: Name = Name.special("<${diagnostic.reason}>")
|
||||
override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
@@ -14,11 +16,11 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirErrorTypeRef : FirResolvedTypeRef() {
|
||||
abstract class FirErrorTypeRef : FirResolvedTypeRef(), FirDiagnosticHolder {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val annotations: List<FirAnnotationCall>
|
||||
abstract override val type: ConeKotlinType
|
||||
abstract val reason: String
|
||||
abstract override val diagnostic: FirDiagnostic
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorTypeRef(this, data)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.types.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
@@ -20,10 +21,10 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
class FirErrorTypeRefImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val reason: String
|
||||
override val diagnostic: FirDiagnostic
|
||||
) : FirErrorTypeRef(), FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val type: ConeKotlinType = ConeClassErrorType(reason)
|
||||
override val type: ConeKotlinType = ConeClassErrorType(diagnostic.reason)
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
|
||||
@@ -48,7 +48,9 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
@@ -294,10 +296,18 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformElement(anonymousObject, data)
|
||||
}
|
||||
|
||||
open fun transformDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): CompositeTransformResult<FirDiagnosticHolder> {
|
||||
return transformElement(diagnosticHolder, data)
|
||||
}
|
||||
|
||||
open fun transformLoop(loop: FirLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(loop, data)
|
||||
}
|
||||
|
||||
open fun transformErrorLoop(errorLoop: FirErrorLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(errorLoop, data)
|
||||
}
|
||||
|
||||
open fun transformDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(doWhileLoop, data)
|
||||
}
|
||||
@@ -734,10 +744,18 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformAnonymousObject(anonymousObject, data)
|
||||
}
|
||||
|
||||
final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): CompositeTransformResult<FirDiagnosticHolder> {
|
||||
return transformDiagnosticHolder(diagnosticHolder, data)
|
||||
}
|
||||
|
||||
final override fun visitLoop(loop: FirLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformLoop(loop, data)
|
||||
}
|
||||
|
||||
final override fun visitErrorLoop(errorLoop: FirErrorLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformErrorLoop(errorLoop, data)
|
||||
}
|
||||
|
||||
final override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformDoWhileLoop(doWhileLoop, data)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,9 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
@@ -208,8 +210,12 @@ abstract class FirVisitor<out R, in D> {
|
||||
|
||||
open fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: D): R = visitElement(anonymousObject, data)
|
||||
|
||||
open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): R = visitElement(diagnosticHolder, data)
|
||||
|
||||
open fun visitLoop(loop: FirLoop, data: D): R = visitElement(loop, data)
|
||||
|
||||
open fun visitErrorLoop(errorLoop: FirErrorLoop, data: D): R = visitElement(errorLoop, data)
|
||||
|
||||
open fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: D): R = visitElement(doWhileLoop, data)
|
||||
|
||||
open fun visitWhileLoop(whileLoop: FirWhileLoop, data: D): R = visitElement(whileLoop, data)
|
||||
|
||||
@@ -48,7 +48,9 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
@@ -292,10 +294,18 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitElement(anonymousObject)
|
||||
}
|
||||
|
||||
open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder) {
|
||||
visitElement(diagnosticHolder)
|
||||
}
|
||||
|
||||
open fun visitLoop(loop: FirLoop) {
|
||||
visitElement(loop)
|
||||
}
|
||||
|
||||
open fun visitErrorLoop(errorLoop: FirErrorLoop) {
|
||||
visitElement(errorLoop)
|
||||
}
|
||||
|
||||
open fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop) {
|
||||
visitElement(doWhileLoop)
|
||||
}
|
||||
@@ -732,10 +742,18 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitAnonymousObject(anonymousObject)
|
||||
}
|
||||
|
||||
final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: Nothing?) {
|
||||
visitDiagnosticHolder(diagnosticHolder)
|
||||
}
|
||||
|
||||
final override fun visitLoop(loop: FirLoop, data: Nothing?) {
|
||||
visitLoop(loop)
|
||||
}
|
||||
|
||||
final override fun visitErrorLoop(errorLoop: FirErrorLoop, data: Nothing?) {
|
||||
visitErrorLoop(errorLoop)
|
||||
}
|
||||
|
||||
final override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: Nothing?) {
|
||||
visitDoWhileLoop(doWhileLoop)
|
||||
}
|
||||
|
||||
+7
-4
@@ -59,7 +59,10 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val anonymousFunction = element("AnonymousFunction", Declaration, function, expression)
|
||||
val anonymousObject = element("AnonymousObject", Declaration, klass, expression)
|
||||
|
||||
val diagnosticHolder = element("DiagnosticHolder", Diagnostics)
|
||||
|
||||
val loop = element("Loop", Expression, statement, targetElement, annotationContainer)
|
||||
val errorLoop = element("ErrorLoop", Expression, loop, diagnosticHolder)
|
||||
val doWhileLoop = element("DoWhileLoop", Expression, loop)
|
||||
val whileLoop = element("WhileLoop", Expression, loop)
|
||||
|
||||
@@ -88,8 +91,8 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val arrayOfCall = element("ArrayOfCall", Expression, expression, call)
|
||||
val arraySetCall = element("ArraySetCall", Expression, qualifiedAccess, call)
|
||||
val classReferenceExpression = element("ClassReferenceExpression", Expression, expression)
|
||||
val errorExpression = element("ErrorExpression", Expression, expression)
|
||||
val errorFunction = element("ErrorFunction", Declaration, function)
|
||||
val errorExpression = element("ErrorExpression", Expression, expression, diagnosticHolder)
|
||||
val errorFunction = element("ErrorFunction", Declaration, function, diagnosticHolder)
|
||||
val qualifiedAccessExpression = element("QualifiedAccessExpression", Expression, expression, qualifiedAccess)
|
||||
val functionCall = element("FunctionCall", Expression, qualifiedAccessExpression, call)
|
||||
val componentCall = element("ComponentCall", Expression, functionCall)
|
||||
@@ -113,7 +116,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val wrappedDelegateExpression = element("WrappedDelegateExpression", Expression, wrappedExpression)
|
||||
|
||||
val namedReference = element("NamedReference", Reference, reference)
|
||||
val errorNamedReference = element("ErrorNamedReference", Reference, namedReference)
|
||||
val errorNamedReference = element("ErrorNamedReference", Reference, namedReference, diagnosticHolder)
|
||||
val superReference = element("SuperReference", Reference, reference)
|
||||
val thisReference = element("ThisReference", Reference, reference)
|
||||
val controlFlowGraphReference = element("ControlFlowGraphReference", Reference, reference)
|
||||
@@ -125,7 +128,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val resolvedCallableReference = element("ResolvedCallableReference", Reference, resolvedNamedReference)
|
||||
|
||||
val resolvedTypeRef = element("ResolvedTypeRef", TypeRef, typeRef)
|
||||
val errorTypeRef = element("ErrorTypeRef", TypeRef, resolvedTypeRef)
|
||||
val errorTypeRef = element("ErrorTypeRef", TypeRef, resolvedTypeRef, diagnosticHolder)
|
||||
val delegatedTypeRef = element("DelegatedTypeRef", TypeRef, typeRef)
|
||||
val typeRefWithNullability = element("TypeRefWithNullability", TypeRef, typeRef)
|
||||
val userTypeRef = element("UserTypeRef", TypeRef, typeRefWithNullability)
|
||||
|
||||
+5
-7
@@ -224,11 +224,9 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
noSource()
|
||||
}
|
||||
|
||||
impl(errorExpression)
|
||||
|
||||
impl(loop, "FirErrorLoop") {
|
||||
impl(errorLoop) {
|
||||
default("block", "FirEmptyExpressionBlock()")
|
||||
default("condition", "FirErrorExpressionImpl(source, \"error loop\")")
|
||||
default("condition", "FirErrorExpressionImpl(source, diagnostic)")
|
||||
defaultNull("label")
|
||||
useTypes(emptyExpressionBlock)
|
||||
}
|
||||
@@ -496,13 +494,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
impl(resolvedTypeRef)
|
||||
|
||||
val errorTypeRefImpl = impl(errorTypeRef) {
|
||||
default("type", "ConeClassErrorType(reason)")
|
||||
default("type", "ConeClassErrorType(diagnostic.reason)")
|
||||
useTypes(coneClassErrorTypeType)
|
||||
}
|
||||
|
||||
impl(errorFunction) {
|
||||
defaultNull("receiverTypeRef", "body", withGetter = true)
|
||||
default("returnTypeRef", "FirErrorTypeRefImpl(null, reason)")
|
||||
default("returnTypeRef", "FirErrorTypeRefImpl(null, diagnostic)")
|
||||
useTypes(errorTypeRefImpl)
|
||||
}
|
||||
|
||||
@@ -524,7 +522,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
impl(errorNamedReference) {
|
||||
default("name", "Name.special(\"<\$errorReason>\")")
|
||||
default("name", "Name.special(\"<\$diagnostic.reason>\")")
|
||||
defaultNull("candidateSymbol", withGetter = true)
|
||||
}
|
||||
|
||||
|
||||
+4
-13
@@ -59,6 +59,10 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+field("calleeReference", reference).withTransform()
|
||||
}
|
||||
|
||||
diagnosticHolder.configure {
|
||||
+field("diagnostic", firDiagnosticType)
|
||||
}
|
||||
|
||||
declaration.configure {
|
||||
+field("session", firSessionType)
|
||||
+field("resolvePhase", resolvePhaseType, withReplace = true).apply { isMutable = true }
|
||||
@@ -95,7 +99,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
|
||||
errorFunction.configure {
|
||||
parentArg(function, "F", errorFunction)
|
||||
+stringField("reason")
|
||||
+symbol("FirErrorFunctionSymbol")
|
||||
}
|
||||
|
||||
@@ -398,10 +401,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+intField("componentIndex")
|
||||
}
|
||||
|
||||
errorExpression.configure {
|
||||
+stringField("reason")
|
||||
}
|
||||
|
||||
expressionWithSmartcast.configure {
|
||||
+field("originalExpression", qualifiedAccessExpression)
|
||||
+field("typesFromSmartcast", "Collection<ConeKotlinType>", null, customType = coneKotlinTypeType)
|
||||
@@ -493,10 +492,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+field("type", coneKotlinTypeType)
|
||||
}
|
||||
|
||||
errorTypeRef.configure {
|
||||
+stringField("reason")
|
||||
}
|
||||
|
||||
delegatedTypeRef.configure {
|
||||
+field("delegate", expression, nullable = true)
|
||||
+field(typeRef)
|
||||
@@ -533,10 +528,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+field(varianceType)
|
||||
}
|
||||
|
||||
errorNamedReference.configure {
|
||||
+stringField("errorReason")
|
||||
}
|
||||
|
||||
contractDescription.configure {
|
||||
+fieldList("effects", effectDeclarationType)
|
||||
}
|
||||
|
||||
+2
-1
@@ -62,4 +62,5 @@ val classSymbolType = type("fir.symbols.impl", "FirClassSymbol")
|
||||
|
||||
val pureAbstractElementType = generatedType("FirPureAbstractElement")
|
||||
val effectDeclarationType = type("fir.contracts.description", "ConeEffectDeclaration")
|
||||
val emptyContractDescriptionType = generatedType("contracts.impl", "FirEmptyContractDescription")
|
||||
val emptyContractDescriptionType = generatedType("contracts.impl", "FirEmptyContractDescription")
|
||||
val firDiagnosticType = generatedType("diagnostics", "FirDiagnostic")
|
||||
+1
@@ -125,6 +125,7 @@ class Element(val name: String, kind: Kind) : AbstractElement {
|
||||
Reference("references"),
|
||||
TypeRef("types"),
|
||||
Contracts("contracts"),
|
||||
Diagnostics("diagnostics"),
|
||||
Other("")
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -358,7 +358,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
|
||||
override fun visitNamedReference(namedReference: FirNamedReference, data: StringBuilder) {
|
||||
if (namedReference is FirErrorNamedReference) {
|
||||
data.append("[ERROR : ${namedReference.errorReason}]")
|
||||
data.append("[ERROR : ${namedReference.diagnostic.reason}]")
|
||||
return
|
||||
}
|
||||
visitElement(namedReference, data)
|
||||
@@ -416,7 +416,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
functionCall.typeRef.accept(this, data)
|
||||
}
|
||||
}
|
||||
is FirErrorNamedReference -> data.append("[ERROR : ${callee.errorReason}]")
|
||||
is FirErrorNamedReference -> data.append("[ERROR : ${callee.diagnostic.reason}]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
}
|
||||
|
||||
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: StringBuilder) {
|
||||
data.append("[ERROR : ${errorTypeRef.reason}]")
|
||||
data.append("[ERROR : ${errorTypeRef.diagnostic.reason}]")
|
||||
}
|
||||
|
||||
override fun visitResolvedFunctionTypeRef(resolvedFunctionTypeRef: FirResolvedFunctionTypeRef, data: StringBuilder) {
|
||||
|
||||
Reference in New Issue
Block a user