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
Tamas Vajk
8ebdaf1fc2
Kotlin: Fix parent class lookup from field initializers
2022-05-16 12:14:28 +02:00
Tamás Vajk
f7d2b2767c
Merge pull request #9151 from tamasvajk/kotlin-comments-variables-1
...
Kotlin: Handle variables as comment owners
2022-05-16 09:32:19 +02:00
Chris Smowton
81baca2c17
Fix initializer field flow by extracting field finality
2022-05-13 17:40:58 +01:00
Ian Lynagh
7ef9a19085
Merge pull request #9131 from github/igfoo/capture_output
...
Kotlin: Don't use capture_output or text
2022-05-13 15:59:14 +01:00
Ian Lynagh
b94597568a
Kotlin: Write the log file as Line-delimited JSON
2022-05-13 15:36:30 +01:00
Ian Lynagh
3ae5e1a5f7
Kotlin: Add a LogMessage class
2022-05-13 15:36:30 +01:00
Tamas Vajk
ef08554adb
Fix extraction of reflective call generated by Parcelize
2022-05-13 14:01:37 +02:00
Tamas Vajk
7376ec5d42
Handle variables as comment owners
2022-05-13 13:58:06 +02:00
Chris Smowton
63dadd88aa
Revert "Identify data classes during extraction"
...
This reverts commit a61ba65c9f2182a578a7f4dbdb1c1657197f16cd, pending
adding a proper upgrade script for the DB change.
2022-05-12 22:37:30 +01:00
Tamas Vajk
cc92c6517b
Fix labels of extension function parameters
2022-05-12 22:37:06 +01:00
Tamas Vajk
ccaafd74f3
Fix declaring type of companion field
2022-05-12 22:37:06 +01:00
Tamas Vajk
8b1a7c845c
Fix return type of <clinit> methods
2022-05-12 22:37:06 +01:00
Tamas Vajk
59581439dd
Fix colliding property accessor and function names
2022-05-12 22:37:06 +01:00
Tamas Vajk
857a74cf14
Adjust class label generation to handle classes in field initializers
2022-05-12 22:37:06 +01:00
Chris Smowton
2600dcd182
Fix extracting type accesses relating to proprerty getters/setters and SAM-converted methods
...
These should be handled the same as regular methods: extract type accesses for parameters and methods only if we're extracting "from source", i.e. at some point we're descended from extractFileContents.
2022-05-12 22:37:06 +01:00
Chris Smowton
301fa11450
Only extract parameter and method type-accesses once
...
Previously we extracted them whenever something was non-external, but this led to re-extraction when an instance of a generic type defined in source was extracted multiple times.
2022-05-12 22:37:06 +01:00
Chris Smowton
8d970a3cbd
Don't extract private members of instantiated or external classes
...
This is both consistent with the Java extractor's behaviour, and prevents us from trying to refer to anonymous types (e.g. anonymous objects that directly initialize properties) out of scope.
2022-05-12 22:37:06 +01:00
Tamas Vajk
fbae0f5053
Revert dataflow changes, extract actual iterator function
2022-05-12 22:37:06 +01:00
Chris Smowton
7e17074b41
Allow arithmetic functions not mapping to Java equivalents
2022-05-12 22:36:28 +01:00
Chris Smowton
b1849f5f0a
Expand error message
2022-05-12 22:36:28 +01:00
Chris Smowton
16af811b69
Allow imprecise matching for Kotlin -> Java method translation
...
This allows the particular case of Collection.toArray(IntFunction<T>) to match, since both Java and Kotlin functions take an IntFunction<T> but they use different function-local type variables.
This would also allow toArray(Array<T>) to work similarly.
2022-05-12 22:36:28 +01:00
Chris Smowton
71d2e7be3e
Don't replace own callables, and use a more exact replacement-finding test
2022-05-12 22:36:28 +01:00
Chris Smowton
ce87a89009
Replace Map and similar functions with their Java cousins
...
This didn't appear to be necessary because the Kotlin and Java versions of Map (for example) are designed to be compatible, but in certain cases their functions have the same erasure but not the same type (e.g. Map.getOrDefault(K, V) vs. Map.getOrDefault(Object, V).
These have different erasures which was leading to callable-binding inconsistencies.
2022-05-12 22:36:28 +01:00
Tamas Vajk
fa0bd0366c
Fix extension property labels
2022-05-12 22:36:28 +01:00
Tamas Vajk
25fce5f6bb
Identify data classes during extraction
2022-05-12 22:36:28 +01:00
Chris Smowton
1e78f2893c
Add test for special method getters
2022-05-12 22:36:28 +01:00
Chris Smowton
12e3401ae0
Map special getters onto their correct JVM names
...
These include Collection.size() for example, which has a Kotlin property called `size` but whose getter is not named `getSize()`.
These would normally be accounted for using `@JvmName`, but some core methods are lowered by a special compiler pass instead.
2022-05-12 22:36:27 +01:00
Chris Smowton
cb6941d212
Account for JVM type equivalency when recognising unspecialised types
...
(As before, these are not really unspecialised, they are instantiated by their own type parameters, but this replicates the behaviour of the Java extractor)
2022-05-12 22:36:27 +01:00
Ian Lynagh
02101fab6a
Kotlin: Don't use capture_output or text
...
Older python versions don't support them
2022-05-12 14:08:19 +01:00
Tamas Vajk
e8b3bf55fa
Code quality improvements
2022-05-10 19:51:30 +01:00
Tamas Vajk
465a85bb8c
Explicitly check if a when expression is in the expected &&/|| form
2022-05-10 19:51:30 +01:00
Tamas Vajk
3af8273620
Modify extraction of &&/|| to resugar it from when expression
2022-05-10 19:51:30 +01:00
Tamas Vajk
b66a3141f6
Extract functions using their name from JvmName annotation
2022-05-10 19:51:30 +01:00
Tamas Vajk
a24753f552
Extract final modifier on local variables
2022-05-10 19:51:30 +01:00
Tamas Vajk
4efb87a7dd
Extract enum entry initializers
2022-05-10 19:51:30 +01:00
Tamas Vajk
fc5229a0a5
Extract type access expression for static field access in initializer
2022-05-10 19:51:29 +01:00
Tamas Vajk
c6a75957e9
Fix expected files, fix type access extraction of file level static declarations
2022-05-10 19:51:29 +01:00
Tamas Vajk
1e529b2563
Add missing type access expression for static field accesses
2022-05-10 19:51:29 +01:00
Tamas Vajk
f43296a157
Extract type access for enum value access
2022-05-10 19:51:29 +01:00
Tamas Vajk
b5c8d29e40
Extract enum field declarations
2022-05-10 19:51:29 +01:00
Tamas Vajk
d6cbcdc847
Extract type access expression for parameter types
2022-05-10 19:51:29 +01:00
Tamas Vajk
f557719fe5
Extract type access expression for function return types
2022-05-10 19:51:29 +01:00
Chris Smowton
23e3bbea73
Fix: don't treat local classes as unspecialised
...
This shouldn't matter either way since they can't be subject to external references
2022-05-10 19:51:29 +01:00
Chris Smowton
4477482990
Share a class instance, not just a label
2022-05-10 19:51:29 +01:00