Don't extract error expressions when a default value is missing

This is a shortcoming of the Kotlin extractor, but at least this way we don't introduce an inconsistency if the annotation is later seen from .kt source or by the Java extractor
This commit is contained in:
Chris Smowton
2022-11-22 15:11:36 +00:00
parent 5b2834c833
commit 658c7a20cf
3 changed files with 61 additions and 35 deletions

View File

@@ -582,17 +582,9 @@ open class KotlinFileExtractor(
}
// is IrErrorExpression
// null
else -> {
val eId = tw.getFreshIdLabel<DbErrorexpr>()
val type = useType(v?.type ?: pluginContext.irBuiltIns.unitType)
tw.writeExprs_errorexpr(eId, type.javaResult.id, parent, idx)
tw.writeExprsKotlinType(eId, type.kotlinResult.id)
if (v != null) {
tw.writeHasLocation(eId, tw.getLocation(v))
}
eId
}
// Note: emitting an ErrorExpr here would induce an inconsistency if this annotation is later seen from source or by the Java extractor,
// in both of which cases the real value will get extracted.
else -> null
}
}