Commit Graph

747 Commits

Author SHA1 Message Date
Chris Smowton
8ec681e61c Kotlin: bump default CI version to 1.7.20
A bunch of test expectations change because 7f531d8426 means that we now see (a) local variable declarations with source locations covering only their identifier, not the whole statement, and (b) more SYNTHETIC_OFFSET values for the parts of a destructuring assignment
or initialiser, which show up as file.kt:0:0:0:0 in DbLocation form.
2022-11-25 10:19:26 +00:00
Chris Smowton
cf34dbd276 Kotlin: format string literals like the Java annotaton extractor
Java's regular strings are formatted as they appear in source, but we don't easily have this information available in Kotlin. During annotation extraction however it guesses a source rendering because the source is not necessarily available. By formatting to match the annotation extractor, we prepare to ensure consistency with a Java database
when extracting annotations as seen by Kotlin.
2022-11-17 17:28:17 +00:00
Chris Smowton
d6a395ba37 Remove non-longer-needed expected diagnostics 2022-11-16 13:49:59 +00:00
Tamás Vajk
830be92f1d Merge pull request #11089 from tamasvajk/kotlin-enum-ctor-call
Kotlin: Extract missing arguments of enum constructor calls
2022-11-07 12:55:27 +01:00
Chris Smowton
587aa93f6d Merge pull request #11105 from smowton/smowton/fix/use-defaults-method-to-implement-jvmoverloads
Kotlin: use `$default` functions to implement `@JvmOverloads`
2022-11-07 09:54:16 +00:00
Tamas Vajk
44e70afa85 Kotlin: Extract missing arguments of enum constructor calls 2022-11-07 10:07:04 +01:00
Tamas Vajk
16cb4c5aaa Kotlin: Extract extension binary operators 2022-11-03 16:11:23 +01:00
Tamas Vajk
70561cabaf Kotlin: Add test cases for extension binary operators 2022-11-03 16:10:32 +01:00
Chris Smowton
1ea87020c4 Kotlin: use $default functions to implement @JvmOverloads
This avoids extracting the default value expression in more than one place, which causes inconsistencies for e.g. anonymous classes, which expect to have a single `new` expression associated.
2022-11-03 14:48:36 +00:00
Chris Smowton
8eee450c65 Merge pull request #11064 from smowton/smowton/fix/kotlin-inherited-defaults
Kotlin: handle default parameter values inherited from an overridden function
2022-11-02 18:13:14 +00:00
Chris Smowton
197be69425 Merge pull request #11069 from smowton/smowton/fix/kotlin-vararg-constructor-defaults
Kotlin vararg constructors: don't call a default-parameter constructor just because there are no varargs
2022-11-02 16:08:45 +00:00
Chris Smowton
cad268476c Accept test changes re: method source-locs 2022-11-02 14:00:14 +00:00
Chris Smowton
d700fddfdd Kotlin: handle default parameter values inherited from an overridden function 2022-11-02 13:57:53 +00:00
Chris Smowton
4910bf12e9 Kotlin vararg constructors: don't call a default-parameter constructor just because there are no varargs
This is the constructor case of https://github.com/github/codeql/pull/10909
2022-11-01 19:28:56 +00:00
Tamas Vajk
91972d1d1f Kotlin: Fix location (start position) of method calls 2022-10-31 21:08:15 +01:00
Tamás Vajk
e356720c73 Merge pull request #11014 from tamasvajk/kotlin-for-loop-var
Kotlin: Resugar `for` loops
2022-10-31 14:48:21 +01:00
Chris Smowton
8266a22332 Kotlin: fix method types when an inherited method implements a collection type
In this circumstance the compiler seems to generate a specialised version of the implementing function with its argument type replaced by the interface-implementing child class' type parameter. However it stores a back-pointer to the real declared function, which we should use as the call target.
2022-10-29 11:29:04 +01:00
Tamas Vajk
d745381ebe Remove unneeded consistency test output 2022-10-28 14:56:25 +02:00
Tamas Vajk
803a97df7f Kotlin: Resugar for loops with tuples as loop variables 2022-10-28 14:55:50 +02:00
Tamas Vajk
841340b266 Kotlin: Resugar for loops 2022-10-28 14:55:50 +02:00
Tamas Vajk
1e3060598f Kotlin: Add for loop tests 2022-10-28 14:55:50 +02:00
Tamas Vajk
7ceadb0df0 Kotlin: Remove javaEquivalent consistency query
The `javaEquivalent` consistency query is no longer needed, as the `diags` query is now a superset of it.
2022-10-28 10:44:42 +02:00
Tamas Vajk
1727fcb845 Kotlin: fix test to expect diagnostic 2022-10-27 09:14:23 +02:00
Chris Smowton
fac383a3ac Merge pull request #10974 from smowton/smowton/fix/dont-translate-tochar
Kotlin: don't try to call nonexistent `j.l.Number.toChar`
2022-10-26 14:18:03 +01:00
Ian Lynagh
37c40c58d2 Merge pull request #10959 from igfoo/igfoo/diags
Java/Kotlin: Add a diagnostics consistency query
2022-10-26 13:07:01 +01:00
Chris Smowton
004f4be5fb Kotlin: don't try to call nonexistent j.l.Number.toChar
Previously we thought this could be callable because Kotlin's view of `j.l.Integer` inherits `k.Number` which defines `toChar`.
2022-10-25 17:09:05 +01:00
Ian Lynagh
63b64e4daa Kotlin: Test tweaks for the diags consistency query 2022-10-25 16:26:11 +01:00
Chris Smowton
b9f4856d47 Merge pull request #10876 from smowton/smowton/feature/kotlin-default-method-auto-mad
Java models-as-data: infer Kotlin $default models from that of its parent function
2022-10-25 11:58:54 +01:00
Chris Smowton
d171decad7 Accept test changes
All of java.util.{Collection,List,Map} redeclare `boolean equals(Object)` in order to add documentation, as a side-effect creating a real symbol that can be used as a dispatch target.
2022-10-24 19:49:29 +01:00
Chris Smowton
00800017fd Kotlin: make internal constructors' trap labels consistent with the Java extractor
Previously we accidentally named these something like <init>$main, which is a name-mangling the Kotlin compiler applies to internal methods but not to constructors, which look to Java just like regular public constructors.
2022-10-21 16:48:37 +01:00
Chris Smowton
5e28e5a170 Merge pull request #10909 from smowton/smowton/fix/kotlin-varargs-dataflow
Kotlin: Fix varargs dataflow, and varargs default handling
2022-10-21 13:32:34 +01:00
Chris Smowton
1fe9e8457f Kotlin: Fix varargs dataflow, and varargs default handling
Dataflow requires accounting for the fact that the varargs parameter isn't necessarily last in the parameter list in a couple more places. Default handling just requires that if the only null parameter is the varargs argument, and it has no default value, then no $default method is required-- the caller is expected to simply pass nothing (at QL
/ source level) or an empty array (at JVM level).
2022-10-21 11:14:41 +01:00
Chris Smowton
ac013f9d19 Merge pull request #10889 from smowton/smowton/fix/enum-entry-class-warning
Kotlin: Don't warn on extracting an enum-entry class
2022-10-20 22:08:29 +01:00
Chris Smowton
f2749a8878 Don't warn on extracting an enum-entry class 2022-10-20 16:09:45 +01:00
Chris Smowton
e868cdf91b Merge pull request #9876 from smowton/smowton/feature/interface-forwarding
Kotlin: implement default interface forwarding
2022-10-20 10:17:47 +01:00
Chris Smowton
c6b62c934b Merge pull request #10853 from smowton/smowton/fix/specialised-anon-classes
Kotlin: extract called private methods of specialised types, and specialised instances of anonymous types
2022-10-19 16:48:28 +01:00
Chris Smowton
4da480ecc0 Accept test changes resulting from correctly mapping extension methods' default proxies 2022-10-19 15:56:17 +01:00
Chris Smowton
14b8892ced Don't create interface forwarders for other interfaces, and target super accesses correctly
Intermediate interfaces don't need interface forwarders, since the Kotlin compiler won't try to make them non-abstract by synthesising methods.

Super references should always target an immediate superclass, not the ancestor containing the intended implementation.
2022-10-19 15:37:06 +01:00
Tamás Vajk
0069fd9681 Merge pull request #10860 from tamasvajk/kotlin-clinit-static
Kotlin: Add `static` modifier to `clinit`
2022-10-18 11:39:34 +02:00
Chris Smowton
50f99d8e82 Don't produce interface forwarders directed at an abstract target 2022-10-18 10:31:01 +01:00
Chris Smowton
67aa6c7737 Merge pull request #10822 from smowton/smowton/feature/kotlin-collection-literals
Koltin: support collection literals
2022-10-18 09:45:59 +01:00
Tamas Vajk
b67a8877a7 Kotlin: Add static modifier to clinit 2022-10-18 09:26:06 +02:00
Tamás Vajk
543e2f5aab Merge pull request #10678 from tamasvajk/kotlin-type-param-modifiers
Kotlin: Extract type parameter modifiers (`reified`, `in`, `out`)
2022-10-18 09:10:57 +02:00
Chris Smowton
1613e47388 Improve and accept changes to compiler-generated methods test 2022-10-17 18:43:11 +01:00
Chris Smowton
fff9a75ff8 Accept test changes 2022-10-17 18:38:13 +01:00
Chris Smowton
595a66a3a4 Fix extraction of primitive-typed arrays 2022-10-17 18:29:59 +01:00
Chris Smowton
f358be85eb Accept test changes 2022-10-17 18:23:10 +01:00
Chris Smowton
eb97735568 Merge pull request #10797 from smowton/smowton/fix/byte-short-inversion
Kotlin: fix bit-inversion operator for Byte and Short types
2022-10-17 15:05:57 +01:00
Chris Smowton
be53ec9b42 Accept test changes 2022-10-17 11:48:22 +01:00
Chris Smowton
f9d65e42dd Use compiler-provided adapter functions when creating a function reference 2022-10-17 11:48:21 +01:00