Kotlin extractor: use special <nulltype> for null literals · github/codeql@5d3f723 · GitHub
Skip to content

Commit 5d3f723

Browse files
committed
Kotlin extractor: use special <nulltype> for null literals
This matches the Java extractor's treatment of these literals, and so enables dataflow type-tracking to avoid special-casing Kotlin. Natively, Kotlin would regard this as kotlin.Nothing?, the type that can only contain null (kotlin.Nothing without a ? can take nothing at all), which gets Java-ified as java.lang.Void, and this will continue to be used when a null type has to be "boxed", as in representing substituted generic constraints with no possible type.
1 parent cec0544 commit 5d3f723

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 8 additions & 1 deletion

java/ql/test-kotlin1/library-tests/classes/genericExprTypes.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
| generic_anonymous.kt:13:27:13:47 | get(...) | int |
4646
| generic_anonymous.kt:13:40:13:40 | i | int |
4747
| generic_anonymous.kt:17:9:17:29 | T0 | T0 |
48-
| generic_anonymous.kt:17:26:17:29 | null | Void |
48+
| generic_anonymous.kt:17:26:17:29 | null | <nulltype> |
4949
| generic_anonymous.kt:21:9:21:29 | T1 | T1 |
50-
| generic_anonymous.kt:21:26:21:29 | null | Void |
50+
| generic_anonymous.kt:21:26:21:29 | null | <nulltype> |
5151
| generic_anonymous.kt:24:5:32:5 | Unit | Unit |
5252
| generic_anonymous.kt:25:9:31:9 | Unit | Unit |
5353
| generic_anonymous.kt:26:13:26:37 | <Stmt> | new Object(...) { ... } |

java/ql/test-kotlin2/library-tests/classes/genericExprTypes.expected

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)