Kotlin: Remove the last uses of fakeLabel

This commit is contained in:
Ian Lynagh
2022-07-12 17:43:50 +01:00
parent a0636ff843
commit 83edb3b5e9
2 changed files with 10 additions and 17 deletions

View File

@@ -121,14 +121,19 @@ open class KotlinUsesExtractor(
} }
} }
private fun extractErrorType(): TypeResults { private fun extractJavaErrorType(): TypeResult<DbErrortype> {
val typeId = tw.getLabelFor<DbErrortype>("@\"errorType\"") { val typeId = tw.getLabelFor<DbErrortype>("@\"errorType\"") {
tw.writeError_type(it) tw.writeError_type(it)
} }
return TypeResult(typeId, null, "<CodeQL error type>")
}
private fun extractErrorType(): TypeResults {
val javaResult = extractJavaErrorType()
val kotlinTypeId = tw.getLabelFor<DbKt_nullable_type>("@\"errorKotlinType\"") { val kotlinTypeId = tw.getLabelFor<DbKt_nullable_type>("@\"errorKotlinType\"") {
tw.writeKt_nullable_types(it, typeId) tw.writeKt_nullable_types(it, javaResult.id)
} }
return TypeResults(TypeResult(typeId, null, "<CodeQL error type>"), return TypeResults(javaResult,
TypeResult(kotlinTypeId, null, "<CodeQL error type>")) TypeResult(kotlinTypeId, null, "<CodeQL error type>"))
} }
@@ -719,7 +724,7 @@ open class KotlinUsesExtractor(
} }
else -> { else -> {
logger.error("Unrecognised IrSimpleType: " + s.javaClass + ": " + s.render()) logger.error("Unrecognised IrSimpleType: " + s.javaClass + ": " + s.render())
return TypeResults(TypeResult(fakeLabel(), "unknown", "unknown"), TypeResult(fakeLabel(), "unknown", "unknown")) return extractErrorType()
} }
} }
} }
@@ -1276,7 +1281,7 @@ open class KotlinUsesExtractor(
} }
else -> { else -> {
logger.error("Unexpected type argument.") logger.error("Unexpected type argument.")
return TypeResult(fakeLabel(), "unknown", "unknown") return extractJavaErrorType()
} }
} }
} }

View File

@@ -29,15 +29,3 @@ class IntLabel<T>(val i: Int): Label<T> {
class StringLabel<T>(val name: String): Label<T> { class StringLabel<T>(val name: String): Label<T> {
override fun toString(): String = "#$name" override fun toString(): String = "#$name"
} }
// TODO: Remove this and all of its uses
fun <T> fakeLabel(): Label<T> {
if (false) {
println("Fake label")
} else {
val sw = StringWriter()
Exception().printStackTrace(PrintWriter(sw))
println("Fake label from:\n$sw")
}
return IntLabel(0)
}