Commit Graph

1421 Commits

Author SHA1 Message Date
Chris Smowton
e64a8bc79a Use binary names not fqnames for uniquing IrDeclarations
Otherwise we fall into the trap of confusing the two overloads of `MapsKt.iterator` which have differing jvmnames.
2022-06-23 15:34:40 +01:00
Chris Smowton
57ea34d3ff Unique external classes/functions by fqname
Previously we used the IrDeclaration itself, but in Kotlin 1.7 this can be ambiguous because we can get more than one copy of a class in different modules.
2022-06-23 15:34:40 +01:00
Chris Smowton
8c57308661 Prevent extracting hidden functions
I'm not sure how these looked in 1.6 and below yet, but in 1.7 they appear with visibility = public, but a descriptor field set to indicate they have a name clash with a 'real' function.
2022-06-23 15:34:40 +01:00
Chris Smowton
2b2c384933 Kotlin: Move from 1.7.0-RC to 1.7.0 2022-06-23 15:34:40 +01:00
Chris Smowton
4899aabb05 Switch to using Kotlin 1.7 by default 2022-06-23 15:34:40 +01:00
Chris Smowton
45c85228bd Implement Kotlin 1.7 support
- Implement getIrStubFromDescriptor for Kotlin 1.7
- Stop using ClassSymbol.signature, which is now only populated for classes built from Kotlin, and noteworthily is null for primitive and other internally-synthesised types.
2022-06-23 15:34:40 +01:00
Ian Lynagh
3b2b884f09 Merge pull request #9683 from igfoo/igfoo/getDiagnosticLocation
Kotlin: Remove unused function getDiagnosticLocation
2022-06-23 14:09:00 +01:00
Ian Lynagh
1713c416c0 Kotlin: Remove unused function getDiagnosticLocation 2022-06-23 13:07:09 +01:00
Tamas Vajk
dabc956dbf Unify loop break/continue statement handling between java and kotlin 2022-06-23 08:45:11 +02:00
Chris Smowton
46e6203493 Merge pull request #9626 from smowton/smowton/fix/dont-emit-synthetic-parameter-names
Kotlin: don't emit synthetic parameter names
2022-06-22 15:30:54 +01:00
Chris Smowton
44cf260762 Merge pull request #9571 from smowton/smowton/fix/array-variance-lowering
Kotlin: Implement array type variance lowering
2022-06-22 13:38:21 +01:00
Chris Smowton
4b825df60c Kotlin: don't emit synthetic parameter names
The QL library already expects these to be missing in some cases and generates its own names when they are absent. Writing synthetic names to the database can produce inconsistencies if the true name is seen later.
2022-06-20 19:19:35 +01:00
Ian Lynagh
875776d91d Merge pull request #9581 from igfoo/igfoo/redundant_cast
Kotlin: Remove a redundant cast
2022-06-20 17:28:49 +01:00
Tamás Vajk
b16fcb72eb Merge pull request #9559 from tamasvajk/kotlin-fix-parcelize-symbols-3
Kotlin: substitute fake Parcelize functions with their real equivalent ones
2022-06-20 13:05:23 +02:00
Chris Smowton
92b8c0f864 Merge pull request #9563 from smowton/smowton/fix/name-trap-files-after-jvmnames
Kotlin: Name trap files after jvmnames
2022-06-17 12:32:28 +01:00
Ian Lynagh
9a7ff4bcdf Kotlin: Remove a redundant cast 2022-06-16 14:08:12 +01:00
Chris Smowton
a2c0fe4edb Fix Kotlin single-version build when the best candidate has trailing version info
For example, 1.7.0-RC would previously be truncated to 1.7.0 resulting in failure to build the single-version distro as all candidate alternate-version kotlin files would be ignored.
2022-06-16 13:25:59 +01:00
Chris Smowton
2d57d3aa78 Implement array type variance lowering
Kotlin permits introducing a `? extends ...` wildcard against an Array even though the class is final, so long as its argument itself can be extended (i.e. isn't final or is another array type satisfying this condition).

Contravariant arrays get lowered to Object[], and are subject to automatic `extends` wildcard introduction, unless their element type was already Any.
2022-06-15 18:36:56 +01:00
Chris Smowton
90e8d4e1de Name trap files after jvmnames
This should lead to better Java/Kotlin correspondence since the Java extractor will naturally name trap files for JVM names, and avoids a specific bug (tested) where MapsKt.iterator's two overloads (one taking `Map` and one `MutableMap`) are JvmName'd differently since their Java-lowered signatures would be identical. Without this change only
one of the iterator overloads would get extracted leaving the other one a dangling reference.
2022-06-15 11:55:58 +01:00
Tamas Vajk
c722921276 Kotlin: substitute fake Parcelize functions with their real equivalent ones 2022-06-15 10:35:48 +02:00
Chris Smowton
d390dc0316 Map java.lang.Number methods to their Java equivalents 2022-06-14 21:44:54 +01:00
Chris Smowton
3901f57550 Fix: don't crash when local functions happen to share the name of a function with a special JVM name 2022-06-14 21:44:54 +01:00
Chris Smowton
837bef60fe Add java.lang.Enum ordinal and name accessors to special-cased JVM names
Kotlin represents these as read-only properties with unusual getter names.
2022-06-14 21:44:54 +01:00
Chris Smowton
d151bf632c Kotlin: Rewrite MutableList.removeAt(int) -> remove(int)
The Kotlin authors changed this to avoid a clash on List<Int>, but we must reverse the renaming so the Kotlin and Java views of the same class file extract alike.
2022-06-14 21:44:54 +01:00
Chris Smowton
a9f43889ea Fix wildcard introduction vs. constructor parameters
Previously we handled the case of *methods* with potentially-wildcarded types that Java nontheless constrains to be invariant, but missed out the constructor case.
2022-06-14 12:07:49 +01:00
Ian Lynagh
7c5a4909c6 Merge pull request #9468 from igfoo/igfoo/overloads
Kotlin: Put overloads together
2022-06-13 10:44:55 +01:00
Ian Lynagh
bdae353d4d Merge pull request #9475 from igfoo/igfoo/builddir
Kotlin: Do each build in its own directory
2022-06-13 10:44:36 +01:00
Ian Lynagh
ae472f32de Merge pull request #9453 from igfoo/igfoo/sam
Kotlin: Simplify samMember computation
2022-06-13 10:44:18 +01:00
Ian Lynagh
d8edc83ea2 Merge pull request #9451 from igfoo/igfoo/useValueParameter
Kotlin: Remove some redundant code
2022-06-13 10:43:54 +01:00
Ian Lynagh
669c1faf29 Kotlin: Do each build in its own directory
This can make life easier when debugging.
2022-06-10 15:01:37 +01:00
Ian Lynagh
6055aaf048 Kotlin: Put overloads together
Makes it easier when reading the code.

The substituteTypeArguments functions aren't actually overloads, but I
think the same applies.
2022-06-09 17:43:11 +01:00
Ian Lynagh
5c9fea2283 Kotlin: Remove unused idOverride argument to extractFunction 2022-06-07 11:34:43 +01:00
Ian Lynagh
33e11b3014 Kotlin: Simplify samMember computation 2022-06-07 11:11:00 +01:00
Ian Lynagh
763f869e3f Kotlin: Remove some redundant code 2022-06-06 20:49:36 +01:00
Tamas Vajk
0a484aadf1 Improve code quality based on PR review 2022-06-03 11:17:13 +02:00
Tamas Vajk
ba5cf5b1b2 Kotlin: Fix fake raw type symbols used by the Parcelize plugin 2022-06-03 11:17:13 +02:00
Chris Smowton
8b1605a617 Merge pull request #9405 from smowton/smowton/fix/restore-wildcard-types
Kotlin: Introduce / restore implied wildcard types
2022-06-02 13:26:11 +01:00
Chris Smowton
efc534abe7 Add implied wildcards when extracting type parameter bounds
kotlinc seems to always insert wildcards where type parameter variance implies them, and ignores @JvmSuppressWildcards at least in 1.6.20.
2022-06-02 11:37:15 +01:00
Chris Smowton
910bb51094 Extract WildcardTypeAccesses
Their absence became more noticeable now that more implicit wildcards are being produced.
2022-06-02 10:31:08 +01:00
Tamás Vajk
d7b06aa2ba Merge pull request #9401 from tamasvajk/kotlin-cleanup
Kotlin: Reuse `codeQlWithHasQuestionMark`
2022-06-02 10:24:17 +02:00
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