Commit Graph

330 Commits

Author SHA1 Message Date
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
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
Ian Lynagh
83a3ae64c4 Kotlin: Accept test changes 2022-10-19 12:14:39 +01:00
Ian Lynagh
e6e0fe0cd4 Kotlin: Tweak custom_plugin/diagnostics test 2022-10-19 12:14:38 +01:00
Chris Smowton
b148e3168f Java models-as-data: infer Kotlin $default models from that of its parent function 2022-10-18 18:17:08 +01:00
Chris Smowton
fff9a75ff8 Accept test changes 2022-10-17 18:38:13 +01:00
Chris Smowton
e8a35983ee Implement Kotlin default interface method forwarding
Kotlin's implementation of defaults depends on the -Xjvm-default setting (or the @JvmDefault deprecated annotation, not implemented here): by default, actual interface class files don't use default method, and any class that would inherit one instead implements the interface calling a static method defined on TheInterface$DefaultImpls. With
-Xjvm-default=all or =all-compatibility, real interface default methods are emitted, with the latter retaining the DefaultImpls methods so that other Kotlin can use it.

Here I adopt a hybrid solution: create a real default method implementation, but also emit a forwarding method like `@override int f(int x) { return super.TheInterface.f(x); }`, because the Java extractor will see `MyClass.f` in the emitted class file and try to dispatch directly to it. The only downside is that we emit a default interface
method body for a prototype that will appear to be `abstract` to the Java extractor and which it will extract as such. I work around this by tolerating the combination `default abstract` in QL. The alternative would be to fully mimic the DefaultImpls approach, giving 100% fidelity to kotlinc's strategy and therefore no clash with the Java
extractor's view of the world.
2022-10-17 18:38:13 +01:00
Tamas Vajk
f2e2e3bc1d Kotlin: extract protected modifier from java class files 2022-10-10 18:02:21 +02:00
Tamas Vajk
15aab711c7 Kotlin: Add test showing missing java modifier 2022-10-10 18:01:38 +02:00
Chris Smowton
289843eb83 Remove accidentally duplicated test
This was moved to a unit test, but the integration test version was somehow retained.
2022-10-06 16:00:56 +01:00
Chris Smowton
86e5e4c4bc Accept test changes 2022-10-06 12:40:04 +01:00
Ian Lynagh
db673c0355 Merge pull request #10646 from tamasvajk/kotlin-java-kotlin-function-mapping
Kotlin: Simplify `kotlinFunctionToJavaEquivalent`
2022-10-04 13:46:22 +01:00
Chris Smowton
d3d3ce843a Kotlin: Implement JvmOverloads annotation
This generates functions that omit parameters with default values, rightmost first, such that Java can achieve a similar experience to Kotlin (which represents calls internally as if the default was supplied explicitly, and/or uses a $default method that supplies the needed arguments).

A complication: combining JvmOverloads with JvmStatic means that both the companion object and the surrounding class get overloads.
2022-10-03 15:28:55 +01:00
Tamas Vajk
90b28f04d8 Accept integration test changes 2022-10-03 12:10:08 +02:00
Tamas Vajk
121a5645b8 Kotlin: extract operator expression when operator is in method call form 2022-09-30 13:48:53 +02:00
Tamas Vajk
463173eae4 Accept integration test changes 2022-09-28 10:26:58 +02:00
Tamas Vajk
16836de02b Code quality improvment to simplify test QL 2022-09-14 15:15:06 +02:00
Tamas Vajk
a68b61f50a Kotlin: adjust expected test results after fixing compiler argument interception 2022-09-14 13:15:29 +02:00
Tamas Vajk
6eccb5e99c Kotlin: Add integration test to show missing compiler arguments 2022-09-14 13:15:29 +02:00
Tamas Vajk
56ef1739a3 Kotlin: fix KFunctionX.invoke extraction 2022-09-08 10:49:10 +02:00
Tamas Vajk
fdf3488500 Kotlin: Add test with extraction error due to missing base class of KFunctionX 2022-09-08 10:49:01 +02:00
Ian Lynagh
3fcfd32eb1 Make *.ql non-executable 2022-08-24 16:55:11 +01:00
Ian Lynagh
a6cee9edf9 Kotlin: Add an integration test for TRAP compression 2022-08-19 13:34:43 +01:00
Chris Smowton
b499ba5aa8 Kotlin: don't extract private setters of external classes
Previously these would get extracted unlike other private methods even if the class was a standard library or other external class. This could cause inconsistencies because if we also compiled the class from source we could end up deciding different names for the property's setter: setXyz$private when seen from source, and setXyz without a
suffix when seen as an external .class file. Avoiding extracting these functions from the external perspective both restores consistency with other kinds of method and avoids these consistency problems.
2022-07-01 15:44:17 +01:00
Chris Smowton
4c6a9772af Merge pull request #9768 from smowton/smowton/fix/internal-method-name-mangling
Kotlin: Mangle names of internal functions to match JVM symbols
2022-07-01 14:33:32 +01:00
Chris Smowton
b9eec13466 Accept integration test changes 2022-06-30 22:21:04 +01:00
Chris Smowton
dd93062101 Kotlin: Mangle names of internal functions to match JVM symbols 2022-06-30 21:56:25 +01:00
Chris Smowton
ab52a020fa Add test 2022-06-30 10:22:56 +01:00
Ian Lynagh
0b312b61e4 Kotlin: qlformat some test queries 2022-06-24 18:35:58 +01:00
Ian Lynagh
31b3c1fff8 Kotlin: Add integration tests 2022-06-24 17:33:58 +01:00