Commit Graph

286 Commits

Author SHA1 Message Date
Ian Lynagh
1efecc099c Kotlin: Avoid infinite recursion when extracting recursive interfaces 2025-10-31 13:42:43 +00:00
Ian Lynagh
709c111522 Kotlin: Add getJvmModuleNameForDeserializedDescriptor wrapper
It has been removed in 2.2.20.
2025-07-23 12:51:12 +01:00
Chris Smowton
a36fc30d44 Fix build for Kotlin 2.2.0 2025-05-13 14:42:06 +01:00
Ian Lynagh
cec503eecd Kotlin: Fix build with 2.1.20-Beta1 2025-01-20 14:31:58 +00:00
Ian Lynagh
a6fce19b0c Kotlin: Fix build with 2.1.0-Beta1 2024-09-25 15:23:35 +01:00
Ian Lynagh
0be52f9660 Kotlin: Follow removal of sourceid column of the fields relation 2024-09-24 14:06:53 +01:00
Ian Lynagh
91dd99d7a6 Kotlin: Fixes for 2.0.20-Beta2 2024-07-16 15:07:34 +01:00
Ian Lynagh
bf611feab3 Kotlin: Reformat code
Using:
    java -jar ktfmt-0.46-jar-with-dependencies.jar --kotlinlang-style java/kotlin-extractor/**/*.kt
2024-01-09 15:33:41 +00:00
Ian Lynagh
02734be287 Kotlin: Fix building with 2.0.255 snapshots
A couple of extension functions were moved
2024-01-08 13:25:25 +00:00
Ian Lynagh
ab891465a4 Kotlin: Don't convert back and forth between ClassId and FqName
This showed up as a bug in Kotlin 2 mode:

We were starting with the Class Id "java/util/Map.Entry", which we then
converted to the FqName "java.util.Map.Entry", and then back to a
Class Id with ClassId.topLevel. This gave us a Class Id that
referenceClass wasn't able to resolve.

Now we just stick with the Class Id that we started with, and the class
can be resolved by Kotlin 2.
2023-10-17 17:01:53 +01:00
Ian Lynagh
30d7f0cf0a Merge pull request #14334 from igfoo/igfoo/ext-frag
Kotlin: Handle IrExternalPackageFragment properly for more external entities
2023-09-28 20:01:52 +01:00
Ian Lynagh
e9482fb096 Kotlin: Differentiate 2 error messages 2023-09-28 14:59:21 +01:00
Ian Lynagh
5db283e86a Kotlin: Fix comment 2023-09-28 14:26:02 +01:00
Ian Lynagh
261ae4ea4d Kotlin: Handle IrExternalPackageFragment properly for more external entities 2023-09-28 12:12:18 +01:00
Ian Lynagh
4d1ceff7df Kotlin: Fix build 2023-09-12 18:28:33 +01:00
Ian Lynagh
eb59bc04cd Kotlin: Add missing imports 2023-08-31 19:28:05 +01:00
Ian Lynagh
d511d46cde Kotlin: Use packageFqName rather than fqName
Upstream master says:
   error: using 'fqName: FqName' is an error. Please use `packageFqName` instead
2023-08-31 19:28:05 +01:00
Ian Lynagh
3b9bd16097 Kotlin: Mark some functions as private 2023-08-15 12:38:47 +01:00
Ian Lynagh
a8b69e5b55 Kotlin: Fix build on old versions 2023-08-15 11:30:23 +01:00
Ian Lynagh
eb27428514 Kotlin: Handle IrExternalPackageFragment when dealing with external decls 2023-08-14 17:37:48 +01:00
Ian Lynagh
72af8ac1e2 Kotlin: Switch to useDeclarationParentOf
This lets us handle Kotlin 2 declarations whose parent is an
IrExternalPackageFragment, indicating that they are in a (multi)file
class.
2023-08-14 17:02:49 +01:00
Ian Lynagh
4f336820de Kotlin: Start handling IrExternalPackageFragment parents 2023-08-14 17:02:48 +01:00
Ian Lynagh
58da62e244 Kotlin: Handle null parent IDs in getFunctionLabel correctly 2023-08-10 18:49:10 +01:00
Ian Lynagh
0eb6d1c76e Kotlin: useFunction might return null 2023-08-09 13:45:15 +01:00
Ian Lynagh
e8f4aee1cf Kotlin: Remove some redundant braces 2023-07-28 17:02:24 +01:00
Ian Lynagh
bfd0a19d85 Kotlin: Define DiagnosticTrapWriter, for type safety
In some cases, we were writing diagnostics to TRAP files where they
shouldn't be written. Such TRAP files don't define #compilation, so TRAP
import gave errors.

Now we use DiagnosticTrapWriter to get the type system to check that we
are writing diagnostics to the right place.
2023-06-21 18:38:27 +01:00
Ian Lynagh
202037e925 Merge pull request #13148 from igfoo/igfoo/arrays
Kotlin: Add some documentation on arrays, and tweak the tests we use for them
2023-05-12 18:52:16 +01:00
Ian Lynagh
826e87f435 Kotlin: Simplify some array tests 2023-05-12 12:54:08 +01:00
Ian Lynagh
ad51767374 Kotlin: Add comment describing Kotlin array predicates 2023-05-12 12:38:05 +01:00
Ian Lynagh
e7d1782eea Merge pull request #13088 from igfoo/igfoo/getTypeParameterParentLabel
Kotlin: Small simplification
2023-05-11 11:59:06 +01:00
Ian Lynagh
9764a8c348 Kotlin: Remove some redundant return statments 2023-05-09 16:25:59 +01:00
Ian Lynagh
968a78e3e6 Kotlin: Small simplification
Merge two `IrFunction` cases into one.
2023-05-09 16:25:20 +01:00
Chris Smowton
3514dd1e4d Java: merge the @class and @interface database types and tables
This will allow the extractor to emit class(id, ...) when all it knows about a class is its name, due to not having it available on the classpath. Previously it would have had to guess whether it belonged to @class or @interface, possibly introducing an inconsistency.
2023-02-14 17:21:23 +00:00
Ian Lynagh
f7d8d16ed3 Kotlin: Fix build for 1.8.0-Beta
The build no longer works for Kotlin < 1.8: We get

    error: class 'org.jetbrains.kotlin.ir.IrElement' was compiled
           with an incompatible version of Kotlin. The binary version
           of its metadata is 1.8.0, expected version is 1.6.0.
2023-01-10 14:41:29 +00:00
Chris Smowton
dd86f7a696 Kotlin: Revert type erasure within $default functions
This imprecise implementation turned out to cause linkage errors, e.g. when type variables in the signatures of member methods were inappropriately erased. For the time being we accept that $default methods despite having erased signatures in keeping with their JVM representation can contain expressions whose types make reference to their
surrounding function or class' type variables, even though they should be out of scope since $default methods are static and don't have type parameters, and need to cope with the inconsistency in QL.
2022-12-12 18:33:22 +00:00
Chris Smowton
26540111ce Factor out common code for referencing an external type 2022-12-09 10:33:03 +00:00
Chris Smowton
00f323c8bd Fix: extract directly exposed fields with static modifier 2022-12-06 20:32:10 +00:00
Chris Smowton
910a1f872d Adjust opt-in required to use string-manipulation functions in Kotlin <= 1.5 2022-12-06 18:35:04 +00:00
Chris Smowton
08e3431107 Also stub class files relating to file classes and top-level declarations 2022-12-06 18:35:04 +00:00
Chris Smowton
ff4baf096f Don't add name mangling to top-level internal functions
Turns out kotlinc only adds this sort of name mangling to class member functions
2022-12-02 20:16:19 +00:00
Chris Smowton
ca04779dfc Kotlin: fix extraction of Java nested wildcards; wildcards in return types
This fixes two mistakes: return-type extraction not imposing a wildcard where a Java prototype explicitly uses one, and nested wildcard detection quietly failing due to not looking through a `JavaWildcardType` correctly.

I add a variant of the `kotlin_java_lowering_wildcards` test where Java prototypes are only seen from Kotlin, to be sure extraction is working as expected.
2022-11-04 11:39:26 +00:00
Chris Smowton
8e240a2e84 Kotlin: drop same-file requirement for overridden parameter labels 2022-11-02 19:28:53 +00:00
Chris Smowton
d6e2f5f4a8 Use ?.not() to negate a nullable boolean 2022-10-28 16:13:55 +01:00
Chris Smowton
1e1c9f639c Avoid Kotlin 1.5+ function firstNotNullOfOrNull 2022-10-28 16:13:55 +01:00
Chris Smowton
24f87ac963 Kotlin: fix wildcard suppression where the annotation applies to a parent type/argument.
In the process I also fix the missed case where suppression can be switched off using a parameterized annotation.
2022-10-28 16:13:55 +01:00
Chris Smowton
28b6e263ec Kotlin: reintroduce pointless wildcards when a Java declaration explicitly uses them
For example, Java code might use `HasOutVariance<? extends String>`, or `HasInVariance<? super Object>`, both of which are needless wildcards and which the Kotlin extractor would previously have refused to reintroduce due to their not specifying a larger type than their bound. However this led to inconsistency with Java extraction, which
extracts the type as it appears in source.

This seems to particularly happen with generated code, e.g. the output of the Kotlin protobuf compiler.
2022-10-26 20:05:27 +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
Chris Smowton
843f847960 Merge pull request #10921 from smowton/smowton/fix/ignore-enhanced-nullability
Kotlin: ignore enhanced nullability when extracting primitive types
2022-10-24 19:43:04 +01:00
Chris Smowton
86e99c497d Merge pull request #10930 from smowton/smowton/fix/external-property-overloads
Kotlin: give external extension properties with matching name and file distinct trap filenames
2022-10-24 11:32:37 +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