Commit Graph

1181 Commits

Author SHA1 Message Date
Chris Smowton
dc7d07ff46 Extract correct implied wildcards for Java classes and @JvmSuppressWildcards-annotated entities
For Java classes this means following the structure of the underlying Java type to determine where the wildcard was really present and where the Java signature ruled it out. The annotation tracking simply means looking for @JvmSuppressWildcards on any surrounding class or function to turn off wildcard introduction by default.
2022-06-01 20:00:22 +01:00
Chris Smowton
37fce6ace9 Restore implicit wildcard types
The Kotlin compiler represents types like List<out CharSequence> internally as List<CharSequence> due to the fact that List's type parameter is covariant, and similarly Comparable<in CharSequence> where Comparable's type parameter is contravariant. However it restores use-site variance when emitting class files, so we must do the same thing for
compatability with Java code.

Note this is a partial solution because it will also add wildcards to Java .class files that *could* have a variance / wildcard but don't -- for example, a Java method could really take an invariant Comparable<CharSequence>, which is only achievable in Kotlin via the @JvmSuppressWildcards annotation. We also don't yet support
@JvmSuppressWildcards given on a surrounding class or function.
2022-06-01 19:58:40 +01:00
Ian Lynagh
e0d9317889 Merge pull request #9389 from igfoo/igfoo/function_loc_override
Kotlin: Remove extractFunction's location override
2022-06-01 11:46:22 +01:00
Ian Lynagh
703ced3fe9 Merge pull request #9390 from igfoo/igfoo/valueparam
Kotlin: extractValueParameter: Simplify typeSubstitution logic
2022-06-01 11:46:05 +01:00
Ian Lynagh
6be4afcf36 Kotlin: extractValueParameter: Simplify typeSubstitution logic
The type substitution is now done in the wrapper, so the worker doesn't
need to be passed typeSubstitution.
2022-05-31 19:23:54 +01:00
Ian Lynagh
21d69ae819 Kotlin: Remove extractFunction's location override
It wasn't being used.
2022-05-31 17:43:25 +01:00
Tamas Vajk
90fdd7eaf9 Kotlin: Reuse codeQlWithHasQuestionMark 2022-05-31 08:47:25 +02:00
Tamas Vajk
89ffefd45e Kotlin: Change return type of Android specific ConcurrentHashMap.keySet 2022-05-30 23:45:38 +02:00
Chris Smowton
1708719fdf Merge pull request #9343 from smowton/smowton/fix/align-kotlin-java-generic-types
Kotlin: extract methods defined on collections types with their Java signatures
2022-05-30 17:52:58 +01:00
Chris Smowton
49d9d8e7d6 Remove unused imports 2022-05-30 09:59:11 +01:00
Chris Smowton
9ea139566d Disambiguate the names and trap labels of backing fields of extension properties 2022-05-27 16:27:48 +01:00
Chris Smowton
a204c742d8 Associate certain companion object fields with the parent class
Specifically `const`, `lateinit` and `@JvmField` properties get a static field which belongs to the containing class not the companion object, such that Java can address them via the containing class name rather than have to navigate a companion object pointer.
2022-05-27 11:52:39 +01:00
Chris Smowton
a0d5d414b4 Kotlin: extract methods defined on collections types with their Java signatures
Collection, List and Map all define various methods which are either made more generic in Kotlin (e.g. `remove(Object) -> remove(E)`, `containsAll(Collection<?>) -> containsAll(Collection<E>)`), or are made invariant (e.g. `addAll(Collection<? extends E>) -> addAll(Collection<E>)`). This substitutes the types back to their Java signatures,
thereby avoiding differing trap labels and duplicated methods for these types and their descendents.
2022-05-27 11:51:46 +01:00
Chris Smowton
1f2248c1c8 Warn if jar file path not in expected form 2022-05-26 11:59:23 +01:00
Chris Smowton
3bd581a052 Kotlin: use the same mtimes as Java
Previously Kotlin's use of IntelliJ's VirtualFile interface meant we got the containing JAR file's mtime, not that of the individual file entry.
2022-05-26 11:59:23 +01:00
Chris Smowton
98ef22358e Merge pull request #9213 from smowton/smowton/fix/inherited-single-abstract-method
Kotlin: fix implementation of SAM classes that inherit their abstract method
2022-05-24 18:22:55 +01:00
Ian Lynagh
81e876a27b Kotlin: Update build.gradle to include the 1.7.0 RC 2022-05-24 15:14:17 +01:00
Ian Lynagh
d7c17b2bac Kotlin: Add more withHasQuestionMark.kt's 2022-05-24 15:12:29 +01:00
Ian Lynagh
398f86bcc3 Kotlin: Build system tweaks 2022-05-24 15:11:35 +01:00
Ian Lynagh
f46a7c0a0f Kotlin: Add 1.7.0 RC 2022-05-24 15:11:13 +01:00
Ian Lynagh
846edf825a Kotlin: Use withHasQuestionMark wrapper 2022-05-24 15:10:39 +01:00
Ian Lynagh
807f03a878 Kotlin: Add withHasQuestionMark for older releases 2022-05-24 15:10:39 +01:00
Ian Lynagh
4448ba1111 Kotlin: Add compatibility source for 1.7.0-RC 2022-05-24 15:10:39 +01:00
Ian Lynagh
078733c5fe Merge pull request #9263 from tamasvajk/kotlin-versions
Kotlin: Add support for versions 1.5.0, 1.5.10, and 1.5.21
2022-05-24 15:10:09 +01:00
Chris Smowton
edb678f7d0 Rename function 2022-05-24 14:15:40 +01:00
Tamas Vajk
5a54218ac7 Kotlin: Fix missing kotlin to java property mapping 2022-05-24 10:03:17 +02:00
Tamas Vajk
ccc6d2501a Kotlin: adjust build scripts to include versions 1.5.0, 1.5.10, and 1.5.21 2022-05-23 14:19:53 +02:00
Tamas Vajk
0dfbe7adfb Kotlin: Add 1.5.21 specific files 2022-05-23 14:19:53 +02:00
Tamas Vajk
9df9d3ad03 Kotlin: Add 1.5.10 specific files 2022-05-23 14:19:53 +02:00
Tamas Vajk
83a1f687a1 Kotlin: Add 1.5.0 specific files 2022-05-23 14:19:52 +02:00
Tamas Vajk
d3e64f5135 Kotlin: extract non-private members of class supertypes 2022-05-23 10:39:22 +02:00
Tamás Vajk
144937a753 Merge pull request #9154 from tamasvajk/kotlin-error-warning-1
Kotlin: Adjust diagnostic message severity
2022-05-20 16:12:39 +02:00
Ian Lynagh
6652c27591 Merge pull request #9236 from igfoo/igfoo/kotlinc
Kotlin: Use 'which' to find kotlinc
2022-05-20 14:06:59 +01:00
Tamas Vajk
7aafc5f88c Kotlin: Adjust diagnostic message severity
Make extraction messages `warning` if code is still extracted regardless of the reported issue. Make extraction messages `error` if some code is not extracted.
2022-05-20 14:55:16 +02:00
Ian Lynagh
73759705ae Merge pull request #9121 from github/igfoo/mjson
Kotlin: Write the log file as Line-delimited JSON
2022-05-20 13:51:20 +01:00
Ian Lynagh
3fd61581b3 Kotlin: Call the right kotlinc 2022-05-20 12:59:04 +01:00
Ian Lynagh
44efb34447 Kotlin: Use 'which' to find kotlinc
This means we handle kotlinc.batr and kotlinc.cmd on Windows.
2022-05-20 12:44:55 +01:00
Ian Lynagh
d900c3d994 Merge pull request #9221 from smowton/smowton/admin/handle-missing-kotlinc-gracefully
Kotlin: Handle missing kotlinc gracefully
2022-05-20 12:06:06 +01:00
Ian Lynagh
d2cb1aa89c Merge pull request #9218 from igfoo/igfoo/geninst
Kotlin: Avoid "generic specialisation" label collisions
2022-05-20 11:42:22 +01:00
Tamás Vajk
3407b0f055 Merge pull request #9152 from tamasvajk/kotlin-fix-parcelize-reflection-1
Kotlin: Fix extraction of reflective call generated by Parcelize
2022-05-20 09:06:21 +02:00
Chris Smowton
d9f65fe34f Handle missing kotlinc gracefully 2022-05-19 21:54:18 +01:00
Chris Smowton
e80254b0a6 Fix generated implementation of an inherited single abstract method
For example, UnaryOperator<T> extends Function<T, T> without overriding / defining its own `apply` method.
2022-05-19 20:57:54 +01:00
Ian Lynagh
e153f30c01 Kotlin: Avoid "generic specialisation" label collisions
We had a global set of labels for generic specialisations that we'd
extracted, but these labels could contain references to other labels,
and thus you can get false collisions between labels for different TRAP
files. We now only keep the set for a single TRAP file, and live with
the extra TRAP duplication that we get from that.
2022-05-19 17:29:41 +01:00
Ian Lynagh
9e3cde001a Kotlin: Tweak logging
Makes it easier to filter out the peak memory info
2022-05-19 16:59:52 +01:00
Chris Smowton
01aaa6ccbf Merge pull request #9123 from smowton/smowton/fix/type-variable-in-scope-consistency
Kotlin: fix cases where type variables were used out of scope
2022-05-19 16:57:41 +01:00
Ian Lynagh
9b40724dcb Kotlin: Log peak memory usge before and after extractor
Ideally this would be in a more JSON-friendly format, and also in the
database, but this at least makes the information available.
2022-05-19 13:36:11 +01:00
Chris Smowton
4e15f5f8c7 Fix extracted type arguments of kotlin.jvm.functions.FunctionN
Previously we accidentally extracted an argument type instead of the result type.
2022-05-19 11:55:31 +01:00
Chris Smowton
102cdcdab8 Fix type substitution and source locations in SAM-converted generic interface implementations
For example, in implementing Producer<T> by an actual lambda of type () -> Int, the return type should be Int, not T. This produced type-variable-out-of-scope consistency check failures.
2022-05-19 11:55:31 +01:00
Chris Smowton
b09b769932 Extract type parameters without substituting their parent functions
Otherwise references to type variables declared on kotlin.Xyz.someFunction can refer to its Java equivalent java.Xyz.someFunction if it has one.
2022-05-19 11:55:31 +01:00
Tamas Vajk
d4cf877259 Rework parent lookup in isUnspecialised 2022-05-16 14:59:28 +02:00