[KT-58817] Compiler defect workaround

Base method `RawFirBuilder.Visitor.convertElement` has a parameter with
default value, its overridden one in `VisitorWithReplacement` is not
allowed to declare default. So far so good.
During its work the compiler throws an exception:
`java.lang.IllegalArgumentException: No argument for parameter`.
This commit is contained in:
Andrei Klunnyi
2023-05-25 14:28:55 +02:00
committed by Space Team
parent 6535278bd3
commit 3d1e5bb548
2 changed files with 5 additions and 5 deletions
@@ -29,7 +29,7 @@ internal fun buildFileFirAnnotation(
}
}
builder.context.packageFqName = fileAnnotation.containingKtFile.packageFqName
val result = builder.VisitorWithReplacement().convertElement(fileAnnotation) as FirAnnotation
val result = builder.VisitorWithReplacement().convertElement(fileAnnotation, null) as FirAnnotation
replacementApplier?.ensureApplied()
return result
}
@@ -164,10 +164,10 @@ open class RawFirBuilder(
protected open inner class Visitor : KtVisitor<FirElement, FirElement?>() {
private inline fun <reified R : FirElement> KtElement?.convertSafe(): R? =
this?.let(::convertElement) as? R
this?.let { convertElement(it, null)} as? R
private inline fun <reified R : FirElement> KtElement.convert(): R =
convertElement(this) as R
convertElement(this, null) as R
private inline fun <T> buildOrLazy(build: () -> T, noinline lazy: () -> T): T {
return when (mode) {
@@ -262,7 +262,7 @@ open class RawFirBuilder(
return buildErrorExpression(source = null, diagnosticFn())
}
val result = when (val fir = convertElement(this)) {
val result = when (val fir = convertElement(this, null)) {
is FirExpression -> fir
else -> {
return buildErrorExpression {
@@ -298,7 +298,7 @@ open class RawFirBuilder(
}
private inline fun KtExpression.toFirStatement(errorReasonLazy: () -> String): FirStatement {
return when (val fir = convertElement(this)) {
return when (val fir = convertElement(this, null)) {
is FirStatement -> fir
else -> buildErrorExpression {
nonExpressionElement = fir