Commit Graph

48681 Commits

Author SHA1 Message Date
Alexander Udalov eef11c669a Extract TargetedAnnotations out of AnnotationsImpl
Minimize AnnotationsImpl to leave it usable in simple scenarios where
there's no use-site targeted annotations, and use TargetedAnnotations in
the only place in the frontend (AnnotationResolverImpl) where use-sites
were needed.

Also, delete kdoc on Annotations.isEmpty to prevent readers from putting
too much thought into how it works. With the exception of a few places
in the frontend where use-site targeted annotations are still accessed
via the Annotations object, it's now an implementation detail and users
(such as backends, IDE) should not care about them at all, and instead
should just deal with the correct element when processing annotations
2018-09-06 19:13:16 +03:00
Alexander Udalov c0b025b23d Provide default implementation for Annotations.getUseSiteTargetedAnnotations
After this commit, it's overridden only in AnnotationsImpl and
CompositeAnnotations.

Note that although FilteredAnnotations did have a non-trivial
implementation, that class was only used in circumstances where
annotations with use-site targets could not be of any use, so it's safe
to return empty list there now. One could argue that the new semantics
makes more sense: filter "standard" annotations, but don't touch those
with use-site targets because they are not applied to this element
directly, thus should likely not be affected by the filtering
2018-09-06 19:13:16 +03:00
Alexander Udalov f9b9b6908a Remove use-site targeted annotations from LazyAnnotations
LazyAnnotations are only used for classes and files, and in the latter
case it will now contain file annotations as normal annotations, without
the target "file:"
2018-09-06 19:13:15 +03:00
Alexander Udalov 98232265d7 Simplify deserialization of annotations on backing/delegate fields
Instead of returning the list of targeted annotations in
loadCallableAnnotations, add two separate methods to load annotations on
the backing field and on the delegate field of the property
2018-09-06 19:13:15 +03:00
Alexander Udalov ca3cff9a93 Do not write hasAnnotations flag for properties with source-only annotations
This does not break or fix any behavior except the fact that
deserialization will now not try loading annotations on a property which
had no binary- or runtime-retained annotations in the sources
2018-09-06 19:13:14 +03:00
Alexander Udalov 87c0d56618 Drop Annotations.getAllAnnotations 2018-09-06 19:13:14 +03:00
Alexander Udalov 83fbabd628 Drop Annotations.Companion.find/getUseSiteTargetedAnnotation(s) 2018-09-06 19:13:13 +03:00
Alexander Udalov 7271995ff0 Drop Annotations.findAnyAnnotation, DescriptorUtils.getAnnotationByFqName 2018-09-06 19:13:13 +03:00
Alexander Udalov 9d1baaeb56 Simplify backing field generation logic in PropertyCodegen
Inline several methods, remove extra parameters, fix warnings
2018-09-06 19:13:12 +03:00
Alexander Udalov 753191e668 Simplify codegen of annotations, get rid of use-site targets 2018-09-06 19:13:12 +03:00
Alexander Udalov fc87043cb3 Merge use-site targeted annotations into corresponding Annotations
Add PropertyDescriptor.backingField/delegateField to store annotations
on the field directly in an otherwise almost empty descriptor instance,
instead of storing them with use-sites in the corresponding property
descriptor. Instead of AnnotationWithTarget, create AnnotationDescriptor
instances in AnnotationSplitter. Change DescriptorRenderer to render
annotations on "related" declarations when needed, with the explicit
use-site target if applicable.

Most changes in diagnostic test data are related to the fact that
annotations which are known to have an incompatible use-site to the
declaration they're applied at (such as `@param:`-annotation on a
function), are now not loaded at all. It's fine because the code is
erroneous, so it doesn't really matter how do we load annotations with
invalid targets (some of this logic is also changed freely in subsequent
commits). Some changes are also explained by the fact that for example
an annotation on the property which is only applicable to FIELD is now
rendered with an explicit use-site target `@field:`, regardless of
whether it did have that use-site target syntactically or not.

Basically, after this change there's no point in calling
Annotations.getUseSiteTargetedAnnotations/getAllAnnotations anymore
because it's easier and more intuitive to just use Annotations of the
corresponding descriptor -- the backing / delegate field (introduced in
this commit) or the extension receiver / setter parameter (related
behavior was fixed in previous commits). Usages of
use-site-target-related methods will be refactored out in subsequent
commits
2018-09-06 19:13:11 +03:00
Alexander Udalov 8c21e86ded Don't add unapplicable targeted annotations to the container
For example, previously on an (incorrect) code like

    @setparam:Ann
    val x = 42

We added Ann to x's annotations. Not doing this seems more correct and
simplifies implementation a bit.

Test data is NOT changed in this commit because effective changes
somewhat depend on the changes in the subsequent commits. Affected tests
are at compiler/testData/diagnostics/tests/annotations/withUseSiteTarget
2018-09-06 19:13:10 +03:00
Alexander Udalov 0e5544a491 Use AnnotationSplitter for annotations on extension receiver
Instead of using `@receiver:`-targeted annotations on the receiver type,
use normal annotations of the ReceiverParameterDescriptor instance
everywhere
2018-09-06 19:13:10 +03:00
Alexander Udalov 823a24e0a3 Use AnnotationSplitter for annotations on setter parameter
Make it possible to specify annotations of the setter parameter when
constructing the default setter via DescriptorFactory; pass the split
annotations in DescriptorResolver.resolvePropertySetterDescriptor

 #KT-25500 Fixed
2018-09-06 19:13:09 +03:00
Anton Bannykh 779d9aafe7 JS: fix module aliasing for inline imports (KT-26466 fixed)
Consider an import from an inline function invocation. If it is
being called from another inline function, it should be defined
in a special way (e.g. `$$importsForInline$$.foo`) so that
the compiler knows where to load transitive dependencies from.
What's more, the declaration itself should be inside the inline
function wrapper.

Otherwise it should be defined in a regular way (e.g.
`$module$bar.foo` among other top-level imports).

By default the imports are loaded in the first form, and
transformed into the second one when needed. To check
whether this transformation the following predicate is
used: `inlineFunctionDepth == 0`.

At the moment the mentioned variable is increased upon
visiting an inline function declaration (`defineInlineFunction`),
and upon visiting an unknown (not visited before) inline function invocation.

It seems that instead the variable should be increased when processing
an existing inline function wrapper. At that point a new place to
put import definitions (`statementContextForInline`) is set.

Due to way JS code is generated (lambda's come before their call sites)
this issue seems to have been masked. Primary class constructors are a special
case - they come before any other declaration within. Hence a lambda
invocation inside a constructor leads to incorrect import definition.
2018-09-06 19:08:45 +03:00
Mikhael Bogdanov da93ff1a30 Properly cast right-hand side value for inline property setter
#KT-22649 Fixed
2018-09-06 18:04:45 +02:00
Ilya Matveev 5cb8108eec Add builtBy for Kotlin/Native platform libs dependency 2018-09-06 22:59:27 +07:00
Sergey Igushkin 699cff27a7 If a target has no main compilation, don't create a sources JAR
Currently, Android libraries are not published as a part of an MPP
library, and building no sources JAR for them is OK.

Issue #KT-26390
2018-09-06 22:59:27 +07:00
Ilya Matveev 779030da1b Don't use Kotlin/Native home path in up-to-date checks 2018-09-06 22:59:27 +07:00
Ilya Matveev 7b51cfa804 Workaround duplicated libraries for native in IDE 2018-09-06 22:59:27 +07:00
Ilya Matveev 48d8f5eb39 Add libraries provided by the K/N compiler in dependencies 2018-09-06 22:59:27 +07:00
Ilya Matveev e433778268 Switch to Kotlin/Native 0.9 2018-09-06 22:59:27 +07:00
Sergey Igushkin 7ff53deea5 Generate and publish *-sources.jar for each target 2018-09-06 22:59:27 +07:00
Sergey Igushkin 36a81acb5d Fixes for new MPP publishing
* Generate the JARs with the same names as they are published.
  Put the target name in the JAR name's appendix instead of classifier.

* Configure Maven publications eagerly to allow their editing by user.

* Take KotlinVariant's coordinates from the MavenPublication.
  If the user changes Maven coordinates of the publication, this ensures
  the parent component to have the updated information.
2018-09-06 22:59:27 +07:00
Ilya Matveev 440f6996d2 Fix wasm binary output paths 2018-09-06 22:59:27 +07:00
Ilya Matveev 36e8f84797 Add test for static/shared library building 2018-09-06 22:59:27 +07:00
Ilya Matveev bef898509d Allow using strings to set native output kinds 2018-09-06 22:59:27 +07:00
Ilya Matveev cfe7858229 Support static and shared libraries for native in kotlin-mpp 2018-09-06 22:59:27 +07:00
Ilya Matveev 0a685d57c2 Add macos in targets for new MPP integration tests 2018-09-06 22:59:27 +07:00
Sergey Igushkin 577bae763c Add tests for Kotlin/Native in new MPP
* Add K/N variants to the general MPP tests
* Also check the separated publishing
2018-09-06 22:59:27 +07:00
Sergey Igushkin 67bd659390 Fallback to publishing with coordinates inferred from publication
In Gradle < 4.7, there's no `ComponentWithCoordinates` interface, and we
need to make sure that none of our classes implementing this interface
are loaded with older Gradle versions.

Instead of that interface, we can rely on Gradle's metadata generation
heuristic that takes Maven coordinates for the variants from the
corresponding publications.
2018-09-06 22:59:27 +07:00
Ilya Matveev 091e680196 Fix validation warning for Kotlin/Native compilation task 2018-09-06 22:59:27 +07:00
Ilya Matveev ed7da870cf Rename test tasks for native targets 2018-09-06 22:59:27 +07:00
Ilya Matveev c23296a0d8 Publish different targets as different software components 2018-09-06 22:59:27 +07:00
Nikolay Krasko 91308508bd Inject with suffix and prefix arguments in annotations (KT-26584)
#KT-26584 Fixed
2018-09-06 17:39:54 +03:00
Mikhail Zarechenskiy 690762d46c Inline classes ABI: rename equals--impl to equals-impl0 2018-09-06 17:01:01 +03:00
Yan Zhulanow 280a3e3d26 Android Extensions: Support platform modules (KT-26169) 2018-09-06 14:42:23 +03:00
Yan Zhulanow ca4b99b1a0 Maven: Do not consider 'kapt' and 'test-kapt' executions as non-JVM (KT-26211) 2018-09-06 14:42:22 +03:00
Yan Zhulanow 2ec1a89fa1 Use IdePlatform instead of IdePlatformKind in 'Kotlin Facet' project structure tab 2018-09-06 14:42:21 +03:00
Yan Zhulanow a434cb00c6 Do not retain proxy-based components for compiler plugin settings in project model (again) (KT-24444)
The previous approach didn't work because Gradle wraps the copy() result, and the leakage didn't go away.
2018-09-06 14:42:20 +03:00
Yan Zhulanow f55a52b86e MPP: Fix compatibility issue with Android Studio 3.3 Canary 7
'TargetPlatformKind' is still used in AS 3.3 so we can't remove it entirely yet.
2018-09-06 14:42:19 +03:00
Alexander Udalov f90303315d Support array class literals in annotation serializer/deserializer
Note that this change brings an incompatibility: `Array<Foo>::class`
will be seen as `Foo::class` by the old deserializer. We consider this
OK because the compiler never had any logic that relied on reading class
literal arguments correctly (otherwise it wouldn't have worked because
it could only see `Array<*>::class` before this commit), and the support
of annotations on types in JVM reflection is only available in the
upcoming 1.3 release (KT-16795)

 #KT-22069 Fixed
2018-09-06 14:40:06 +03:00
Mikhael Bogdanov f3f93ed6cc Get rid of 'BRIDGE' flag on $default functions
#KT-24415 Fixed
2018-09-06 13:34:00 +02:00
Alexey Sedunov b441c76313 Generate equals/hashCode(): Support content equality from stdlib
#KT-22361 Fixed
2018-09-06 14:28:53 +03:00
Alexey Sedunov 5fcc6cfa0b Change Signature: Retain necessary backquotes in the dialog
#KT-17124 Fixed
2018-09-06 14:28:52 +03:00
Alexey Sedunov 26c02cd8bb Move Left/Right: Support type constraints
#KT-26525 Fixed
2018-09-06 14:28:52 +03:00
Alexey Sedunov a20857beb9 Misc: Do not look for *_main/*_test modules in import test (AS3.2) 2018-09-06 14:28:52 +03:00
Mikhail Zarechenskiy 3dd5a267b8 Refine scope of signed to unsigned conversions
Depend on a module of function declaration, not function call
2018-09-06 14:06:03 +03:00
Nicolay Mitropolsky e80a01a3fd 183: IDEA 183 version set to 183.2153.8 2018-09-06 12:49:00 +03:00
Sergey Igushkin 0ee19cf28f Support -Xcommon-sources in new MPP
In new MPP, add source sets taking part in more than one compilation to
the tasks' `commonSourceSet` in order to pass them as -Xcommon-sources

Issue #KT-26515 Fixed
2018-09-06 12:41:02 +03:00