Merge pull request #9809 from igfoo/igfoo/fakeLabel

Kotlin: Remove the last uses of fakeLabel
This commit is contained in:
Ian Lynagh
2022-08-08 11:54:53 +01:00
committed by GitHub
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\"") {
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\"") {
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>"))
}
@@ -719,7 +724,7 @@ open class KotlinUsesExtractor(
}
else -> {
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 -> {
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> {
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)
}