mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Tolerate nullable references to anonymous classes
This also adds a test case illustrating when this can arise
This commit is contained in:
committed by
Ian Lynagh
parent
8d6ae50d21
commit
c0f3988aaa
@@ -363,19 +363,14 @@ open class KotlinUsesExtractor(
|
||||
classLabelResult.shortName)
|
||||
}
|
||||
|
||||
fun useAnonymousClass(c: IrClass): TypeResults {
|
||||
var res = tw.lm.anonymousTypeMapping[c]
|
||||
if (res == null) {
|
||||
val javaResult = TypeResult(tw.getFreshIdLabel<DbClass>(), "", "")
|
||||
val kotlinResult = TypeResult(tw.getFreshIdLabel<DbKt_notnull_type>(), "", "")
|
||||
tw.writeKt_notnull_types(kotlinResult.id, javaResult.id)
|
||||
res = TypeResults(javaResult, kotlinResult)
|
||||
tw.lm.anonymousTypeMapping[c] = res
|
||||
fun useAnonymousClass(c: IrClass) =
|
||||
tw.lm.anonymousTypeMapping.getOrPut(c) {
|
||||
TypeResults(
|
||||
TypeResult(tw.getFreshIdLabel<DbClass>(), "", ""),
|
||||
TypeResult(fakeKotlinType(), "TODO", "TODO")
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
fun fakeKotlinType(): Label<out DbKt_type> {
|
||||
val fakeKotlinPackageId: Label<DbPackage> = tw.getLabelFor("@\"FakeKotlinPackage\"", {
|
||||
tw.writePackages(it, "fake.kotlin")
|
||||
@@ -396,9 +391,6 @@ open class KotlinUsesExtractor(
|
||||
if (args?.isNotEmpty() == true) {
|
||||
logger.error("Anonymous class with unexpected type arguments")
|
||||
}
|
||||
if (hasQuestionMark) {
|
||||
logger.error("Unexpected nullable anonymous class")
|
||||
}
|
||||
|
||||
return useAnonymousClass(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user