Commit Graph

399 Commits

Author SHA1 Message Date
sebastian.sellmair a3d60f8ed2 [Commonizer] Minor: Don't unnecessarily capture size as local property 2021-09-07 11:36:48 +00:00
sebastian.sellmair f3e55aeac0 [Commonizer] Rename type parameter from 'Context' to 'T'
NullableContextualSingleInvocationCommonizer:
Naming the type parameter 'Context' might provoke different/
misleading intuitions for many.

https://jetbrains.team/im/code/KFc0x1LxezP?message=BDpl60SJkVM&channel=2Ty4Ld4L0Aer

^KT-48567
2021-09-07 11:36:48 +00:00
sebastian.sellmair 2e053be703 [Commonizer] ReturnTypeCommonizer: Only allow covariant nullability for covariant types
The return type of any property with a setter can be considered invariant
and should enable covariant nullability commonization

^KT-48567
2021-09-07 11:36:47 +00:00
sebastian.sellmair 9e34382db5 [Commonizer] Implement TypeNullabilityCommonizer and ReturnTypeCommonizer
^KT-48567 Verification Pending
2021-09-07 11:36:47 +00:00
sebastian.sellmair b13f3599cf [Commonizer] Initial implementation for nullable return type commonization
^KT-48567
2021-09-07 11:36:46 +00:00
sebastian.sellmair f56419cbf8 [Commonizer] Implement ReturnTypeNullabilityCommonizationTest
^KT-48567
2021-09-07 11:36:46 +00:00
sebastian.sellmair 5a63498963 [Commonizer] Use qualified name string for 'UnsafeNumber' annotation
^KT-48459
^KT-48455
2021-08-30 19:25:43 +00:00
sebastian.sellmair e7e3cedf69 [Commonizer] Finalize tests for ^KT-48455 2021-08-30 19:25:43 +00:00
sebastian.sellmair 60ccdf23ea [Commonizer] Choose lower bit width numbers for optimistic number commonization
^KT-48455
2021-08-30 19:25:43 +00:00
sebastian.sellmair 642bb68916 [Commonizer] Rename TargetDependentCommonizer.kt to SingleInvocationCommonizer.kt 2021-08-30 19:25:42 +00:00
sebastian.sellmair f7839e847a [Commonizer] Emit 'UnsafeNumber' for optimistically commonized typealias
^KT-48459 Verification Pending
2021-08-30 19:25:42 +00:00
sebastian.sellmair 814a147a53 [Commonizer] Implement optimistic number commonization for typealias
When typealias point to a number of different bit width on
certain platforms, this implementation will choose
the number type with higher bit width as commonization result
for typealias types and typealias underlying types.

This will effectively port the "analyse code for a single
selected platform" UX approach into HMPP (for numbers only)

^KT-48455 Verification Pending
2021-08-30 19:25:41 +00:00
sebastian.sellmair 565ea2c4f5 [Commonizer] Improve iteration performance in transformer and mergeCirTree
An allocation/iterator free `forEach` is used for lists that
are not intended to be modified at the same time.
2021-08-19 12:19:15 +00:00
sebastian.sellmair e2816ffabb [Commonizer] Rename CirTypeSubstitutor implementations
^KT-48287
^KT-48286
2021-08-19 12:19:14 +00:00
sebastian.sellmair 8aceff3641 [Commonizer] Implement CirUnderscoredTypeAliasSubstitutor
Try substituting TypeAlias types that start with `__` in favour
of TypeAlias without the underscored prefix

^KT-48287 Verification Pending
^KT-48286 Verification Pending
2021-08-19 12:19:14 +00:00
sebastian.sellmair 68e7476765 [Commonizer] ClassSuperTypeCommonizer: Don't find consumed TypeNodes
This commit will also add some simple documentation
to this class and its implementation.

^KT-47430
2021-08-16 10:44:04 +00:00
sebastian.sellmair 1e95717b8d [Commonizer] Implement SimpleCirSupertypesResolverTest
^KT-47430
2021-08-16 10:44:03 +00:00
sebastian.sellmair f64a0efa8b [Commonizer] Respect artificial supertypes when loading dependencies
CirProvided.ExportedForwardDeclarationClass will now correctly
report artificial superclasses.

The InlineTypeAliasCirNodeTransformer does not need to know anything
about artificial supertypes anymore. When inlining any
type alias, it is enough to resolve the type-alias's expansions
supertypes.

^KT-47430
2021-08-16 10:44:03 +00:00
sebastian.sellmair 26ede5d885 [Commonizer] Add small documentation on CirSupertypesResolver
^KT-47430
2021-08-16 10:44:03 +00:00
sebastian.sellmair 9fb41b6334 [Commonizer] CirKnownClassifiers: Store indices and target dependencies as 'TargetDependent'
^KT-47430
2021-08-16 10:44:02 +00:00
sebastian.sellmair 367db345a8 [Commonizer] Do not re-calculate classifier indices for transformer
^KT-47430
2021-08-16 10:44:02 +00:00
sebastian.sellmair dda9bb93f6 [Commonizer] Consider exportForwardDeclarations as dependency
This will make follow-up commits easier:
forward declarations are closer to dependencies than being part
of the library. They will be used in the module, bot not
directly provided.

This commit also enables tracking of provided dependency classifiers
in the CirTreeRoot and CirRootNode

^KT-47430
2021-08-16 10:44:01 +00:00
sebastian.sellmair 3d4e861f05 [Commonizer] ModulesProvider: refactor 'loadModuleInfos()' to property
This is done to signal that accessing this data is indeed lightweight.

^KT-47430
2021-08-16 10:44:01 +00:00
sebastian.sellmair 6c246738a5 [Commonizer] TargetDependent: Support index based access
^KT-47430
2021-08-16 10:44:01 +00:00
sebastian.sellmair dff392f2cd [Commonizer] ClassSuperTypeCommonizer: Include transitive supertypes
This commit still has some left-over todos that shall be done
in a separate commit.

TODOs:
- CirClassifierIndex is calculated once too often
- Reconsider position of classifierIndices in 'CirKnownClassifiers'
- Add documentation/description to complicated 'ClassSuperTypeCommonizer'
- Add documentation/description to CirSupertypesResolver

^KT-47430 Verification Pending
2021-08-16 10:44:00 +00:00
sebastian.sellmair 1857096071 [Commonizer] Implement ClassSuperTypeCommonizer
This implementation runs as regular part of the commonization.
Previous implementation inside the CommonizationVisitor was fully
replaced by it.

As a side effect: CirClass.supertypes was now marked immutable.

^KT-47430 In Progress
2021-08-16 10:44:00 +00:00
sebastian.sellmair 50a343f91e [Commonizer] Deserialize supertypes from provided dependencies
^KT-47430 In Progress
2021-08-16 10:43:59 +00:00
sebastian.sellmair cdfe8d60a4 [Commonizer] InlineTypeAliasCirNodeTransformer: add artificial supertypes
When inlining any TypeAlias pointing towards forward declarations,
the inlined class will respect implicit supertypes.

This logic is analog to
KlibResolvedModuleDescriptorsFactoryImpl.createForwardDeclarationsModule

^KT-47430 In Progress
2021-08-16 10:43:59 +00:00
Alexander Udalov 069e040af9 Fix warnings in kotlin-klib-commonizer 2021-08-06 22:37:00 +02:00
sebastian.sellmair 9500b2d36e [Commonizer] Add HierarchicalCInteropCallableAnnotationCommonizationTest.test single platform not marked as objc 2021-07-15 10:04:45 +00:00
sebastian.sellmair 17ed498390 [Commonizer] approximationKeys: Fix closing ] for type parameter types' upper bounds 2021-07-15 10:04:45 +00:00
sebastian.sellmair daa046589e [Commonizer] approximationKeys: Minor cleanup of buildApproximationSignature 2021-07-15 10:04:44 +00:00
sebastian.sellmair 2c8ce2539b [Commonizer] HierarchicalPropertyCommonizationTest: Add test property with and without setter 2021-07-15 10:04:43 +00:00
sebastian.sellmair 8bab6c3076 [Commonizer] Commonize 'val' and 'var' properties
If a setter is not present on all platforms a fallback private setter
shall be emitted.

^KT-47502 Verification Pending
^KT-47691 Verification Pending
2021-07-15 10:04:43 +00:00
sebastian.sellmair c4d90dc744 [Commonizer] Implement alis type substitution as CirNodeTransformer
This has the advantage, that the substitution only has to run on
functions or properties that are 'incomplete' (missing at least
one other target declaration)

^KT-47433 Verification Pending
2021-07-15 10:04:42 +00:00
sebastian.sellmair 7c450f9884 [Commonizer] Implement CirAliasTypeSubstitutor
This will substitute non-commonizable classifiers with known
type-aliases (which might be commonizable).

A simple example depending on this substitution comes from posix:
Most function and properties use the `FILE` typealias which
is available across all platforms.

Some linux platforms use `__IO_FILE` in their signature, which
is just linux specific. This type substitution will figure out, that
this type can be substituted with `FILE`.

^KT-47433 Verification Pending
2021-07-15 10:04:41 +00:00
sebastian.sellmair 906346b7d9 [Commonizer] Drop CirProperty interface for plain data class 2021-07-15 10:04:41 +00:00
sebastian.sellmair f0feca286e [Commonizer] Drop CirExtensionReceiver interface for plain data class 2021-07-15 10:04:40 +00:00
sebastian.sellmair fdee49ee59 [Commonizer] Drop CirTypeParameter interface for plain data class 2021-07-15 10:04:39 +00:00
sebastian.sellmair 4a4516731a [Commonizer] Drop CirValueParameter interface for plain class 2021-07-15 10:04:39 +00:00
sebastian.sellmair e246a12cd3 [Commonizer] Drop CirFunction interface for plain data class 2021-07-15 10:04:38 +00:00
sebastian.sellmair 0c32abed02 [Commonizer] Remove now unnecessary ArtificialCirDeclaration
This marker interface is not necessary anymore, since no new actuals
will be generated by the Commonizer. It was used to filter declarations
during the serializ
2021-07-15 10:04:37 +00:00
sebastian.sellmair e041532dd2 [Commonizer] InlineSourceBuilder: Also mark ModuleBuilder functions with InlineSourcesCommonizationTestDsl 2021-07-15 10:04:37 +00:00
sebastian.sellmair 87ac436a35 [Commonizer] Implement HierarchicalCInteropCallableAnnotationCommonizationTest 2021-07-15 10:04:36 +00:00
sebastian.sellmair 8acfeb3e17 [Commonizer] Remove computing signatures from metadata 2021-07-15 10:04:36 +00:00
sebastian.sellmair f3ff9814a8 [Commonizer] Create approximation keys based on Cir instead of metadata 2021-07-15 10:04:35 +00:00
Dmitriy Novozhilov 11faf04a4c [Test] Remove dependencies on IDEA classes from test modules
Some of IDEA services (like in `com.intellij/execution`) was copied,
  because they are used in tests but jars with them compiled with
  jdk 11 and we run our tests on jdk 8, so their bytecode can not
  be read
2021-07-08 13:29:19 +03:00
sebastian.sellmair 5b5dddc2d1 [Commonizer] Restore TypeAliasCommonizer's Commutative property & TypeAliasTypeCommonizer: substitute underlying-type arguments
^KT-47574 The fix done here supports only one level of substituting
underlying type-arguments.

HierarchicalTypeAliasCommonizationTest.`KT-47574 - test long typealias chain`
will assert proper behaviour for nested chains.
2021-07-05 09:00:46 +00:00
sebastian.sellmair 1e801e77a2 [Commonizer] HierarchicalClassAndTypeAliasCommonizationTest: Remove unnecessary annotations and reformat file 2021-07-05 09:00:44 +00:00
sebastian.sellmair 684e51b0be [Commonizer] Implement TypeCommonizer as AssociativeCommonizer 2021-07-05 09:00:44 +00:00