Commit Graph

2877 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy e5ee142208 Prohibit @JvmField on properties of inline class types
#KT-26454 Fixed
2018-09-11 10:39:17 +03:00
Mikhail Zarechenskiy 55ef96e5c9 Prohibit @JvmName on functions that are assumed to be mangled
#KT-26454 In Progress
2018-09-11 10:39:16 +03:00
Roman Elizarov e2713501ce Rename SuccessOrFailure to Result and hide Failure from ABI
* The members of Result are isSuccess, isFailure, exceptionOrNull, getOrNull
* The rest of API is implemented via inline-only extensions
* There are two internal functions to hide detailed mechanics of an internal
  Result.Failure class: createFailure and throwOnFailure
* Result.toString is explicit: either Success(v) or Failure(x)

See KT-26538
2018-09-09 11:34:31 +03:00
Alexander Udalov ab3f8db743 Consider property accessor non-default if it has annotations
Otherwise we're not trying to load annotations on the parameter of the
property setter in MemberDeserializer.loadProperty.

Note that after this commit, we could now also assume that if
getter/setter is default, it has no annotations, and thus use
Annotations.EMPTY for default getter/setter in loadProperty. However,
this would cause reflection to work incorrectly on classes compiled by
an older Kotlin compiler, so we'll still try to load annotations on
default accessors for an indefinite time.

 #KT-25499 Fixed
2018-09-07 11:49:42 +03:00
Alexander Udalov 7271995ff0 Drop Annotations.findAnyAnnotation, DescriptorUtils.getAnnotationByFqName 2018-09-06 19:13:13 +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
Ilya Chernikov fd0eb6ee34 Implement support for class literals as annotation arguments...
on deserialization and reflection
2018-08-31 15:17:51 +03:00
Pavel V. Talanov 3a8499b10e Fix a bug where kotlin common classes were seen as missing dependencies
When kotlin referred to them through java signatures
Java resolver ignores expect classes

 #KT-24185 Fixed
2018-08-30 19:37:02 +02:00
Alexander Udalov 896cf61443 Move JVM-specific annotation FQ names and utils to frontend.java 2018-08-27 23:37:06 +02:00
Alexander Udalov ab441dcd96 Drop PropertyDescriptorImpl.setType that takes KotlinType
Only use the other setType that takes an instance of
ReceiverParameterDescriptor. This will make sure that call sites can
use correct receiver annotations
2018-08-27 23:37:05 +02:00
Alexander Udalov 34c033bcaf Take ReceiverParameterDescriptor in FunctionDescriptorImpl.initialize
Instead of just KotlinType. This will allow to pass annotations on the
receiver at call sites
2018-08-27 23:37:04 +02:00
Ilmir Usmanov 4a7703ed66 Implement correct is check for SuspendFunction
Let callable references implement SuspendFunction
Do not generate CHECKCAST SuspendFunction when LV is 1.2

 #KT-25825: Fixed
2018-08-22 16:21:27 +03:00
Alexander Udalov 852760b3b0 Report error on incompatible .kotlin_module files in classpath
Also remove obsolete test wrongAbiVersionNoErrors

 #KT-25973 Fixed
 #KT-26266 Open
2018-08-21 17:12:02 +02:00
Alexander Udalov cd12772bc5 Remove unneeded bunch files related to PsiJavaModule
PSI for modules and related classes are already available in AS3.1
2018-08-10 00:10:37 +02:00
Mikhail Zarechenskiy fa2d159e3f Refactoring: move JVM related diagnostic to ErrorsJvm 2018-08-08 15:47:26 +03:00
Mikhail Zarechenskiy 34cd0e9f6c Do not report warning about useless annotations for JvmStatic properties
#KT-25745 Fixed
2018-08-08 15:47:25 +03:00
Denis Zharkov e3bdde45de Intern canonical classes and parameters names in BinaryClassSignatureParser
Otherwise, a lot of duplicated strings are generated
2018-08-08 15:17:25 +07:00
Denis Zharkov 782f221ab5 Optimize memory-footprint for ClassifierResolutionContext
Use immutable maps for inner classes/type parameters
in nested contexts instead of making copies for each of them
2018-08-08 15:17:25 +07:00
Alexander Udalov f9ed8e7aaf Minor, make org.jetbrains.kotlin.fileClasses.LOG private
To prevent it from being suggested in auto-import
2018-08-07 13:38:30 +02:00
Alexander Udalov 5da8ce844a Minor, move ContentRoot and KotlinSourceRoot to module 'cli'
Also move CONTENT_ROOTS from JVMConfigurationKeys to
CLIConfigurationKeys since it's used on all platforms, not just JVM
2018-08-07 13:38:30 +02:00
Vyacheslav Gerasimov 53b1a8bd37 Remove hacks introduced for 172 platform compatibility 2018-08-02 19:32:18 +03:00
Vyacheslav Gerasimov 0103c0d2fd Switch to 182 platform 2018-08-02 18:17:06 +03:00
Dmitry Petrov 566b5856ec Constructor call normalization mode depends on language version 2018-07-27 09:52:29 +03:00
Dmitry Petrov 44962b00b2 Introduce SyntheticPropertyDescriptor interface 2018-07-19 12:34:45 +03:00
Alexander Udalov 1464a4ac58 Load Java parameter names correctly in BinaryJavaMethod
PSI-based implementation (accessible via
`-Xuse-old-class-files-reading`) loads parameter names from the
"MethodParameters" attribute if it's present, so our own implementation
should as well.

This metadata doesn't seem supported in the java.lang.model.element API
though, so SymbolBasedValueParameter (which is used in `-Xuse-javac`)
will continue to have incorrect behavior for now

 #KT-25193 Fixed
2018-07-18 18:15:09 +02:00
Alexander Udalov 4122021090 Add BinaryVersion to DeserializationContext
This will be useful to implement version-dependent deserialization,
which is needed for gradual fixes of issues in metadata

 #KT-25120 In Progress
2018-07-18 17:58:46 +02:00
Alexander Udalov 1e675bdc01 Simplify implementation of JvmField property in interface companion
Move parts of the logic to the only places where they're needed:
checking for public/final/val is only needed in
JvmFieldApplicabilityChecker, checking the proto flag is only needed in
reflection, checking the JvmField annotation presence is only needed in
backend
2018-07-18 13:24:45 +02:00
Mikhail Zarechenskiy b6db8971e4 Warn about annotations that targets non-existing accessors
#KT-15453 In Progress
2018-07-17 00:22:53 +03:00
Mikhael Bogdanov 1d283d243e Support @JvmField on interface properties
#KT-15807 Fixed
2018-07-16 16:13:15 +02:00
Mikhael Bogdanov f3b419377b Minor. Reformat 2018-07-16 16:13:14 +02:00
Alexander Udalov ce34deb9af Delete DefaultImportProvider, refactor TargetPlatform.defaultImports 2018-07-16 13:45:11 +02:00
Alexander Udalov 1f0fb4823f Simplify DefaultImportProvider, introduce "low priority imports"
Previously, packages `java.lang` and `kotlin.jvm` were imported on JVM
by default on the same rights, causing problems when the same classifier
existed both in `java.lang` and `kotlin.jvm`. Since the only known case
of such conflict were type aliases to JVM classes, the corresponding
classes (expansions of those type aliases) were manually excluded from
default imports. This made the code in DefaultImportProvider complicated
and resulted in multiple problems, regarding both correctness and
performance (see 82364ad3e5, a9f2f5c7d0, dd3dbda719).

This change adds a new concept, a "low priority import", and treats
`java.lang` as such. Since these imports are now separated from the rest
of default imports in LazyImportScope via secondaryClassImportResolver,
conflicts between classifiers are handled naturally: the one from
`kotlin.jvm` always wins (unless the one from `java.lang` is imported
explicitly, of course). This approach is simpler, safer and does not
require any memory to cache anything.

Skip ResolveToJava.kt test for javac-based resolve; it now fails because
of a weird issue which I didn't have time to investigate (this is OK
because it's a corner case of an experimental functionality)
2018-07-16 13:45:11 +02:00
Alexander Udalov dcbb8045bd Disallow function types with big arity on JVM if LV < 1.3 or API < 1.3
The implementation is a bit obscure because this worked on JS since
Kotlin 1.0 and we should not break that; however, on JVM, a diagnostic
will be reported with old language/API version

 #KT-25241 Fixed
2018-07-16 10:41:27 +02:00
Nikolay Krasko 5e35fd1758 Check created javaFileFacadeFqName short name (EA-122324) 2018-07-13 20:00:05 +03:00
Denis Zharkov 89d99e3989 Refine diagnostics for nullability migration warnings
#KT-24911 Fixed
2018-07-13 17:51:21 +03:00
Alexander Udalov e937fe8258 Move PackagePartProvider to module descriptors.jvm 2018-07-10 15:16:49 +02:00
Alexander Udalov 2cb4b7c6d4 Extract MetadataPartProvider out of PackagePartProvider 2018-07-10 15:16:49 +02:00
Alexander Udalov e25bc2865f Remove PackagePartProvider from ResolverForProjectImpl
To be able to move it to JVM-specific modules, and to provide a
replacement for common module analysis
2018-07-10 15:16:49 +02:00
Denis Zharkov 170086250b Support new Continuation API in JVM BE
#KT-24863 Fixed
2018-07-09 15:27:19 +03:00
Alexander Udalov 959c2f4843 Get rid of split packages in descriptors, descriptors.jvm, deserialization
Also move some other files to related packages and reformat moved files
2018-07-06 14:08:35 +02:00
Denis Zharkov 22a9cecfe0 Optimize KotlinPropertyAccessorsReferenceSearcher for case of no kt-files
Property names by accessors can be computed without resolving
java descriptors

 #KT-11477 Fixed
 #KT-16890 Fixed
2018-07-04 14:03:28 +03:00
Denis Zharkov 2d50ad82a5 Optimize SyntheticJavaPropertyDescriptor.Companion::findByGetterOrSetter
Do not force getContributedDescriptors call when we need to request
at most three names
2018-07-04 14:03:28 +03:00
Denis Zharkov 5e6a3673c8 Reformat SyntheticJavaPropertiesScope.kt 2018-07-04 14:03:28 +03:00
Denis Zharkov 3b968351bb Load Java overrides of Kotlin suspend functions as suspend, too
There's still some blind spots:
- Covariant overrides in Java (KT-25036)
- Current implementation assumes that when language version is 1.3 every suspend function
reference only release-coroutines-package Continuation
(we need to check if it's a correct statement)

 #KT-24848 Fixed
 #KT-25036 Open
2018-07-02 14:14:59 +03:00
Alexander Udalov 984e37c7f1 Prohibit explicit usage of kotlin.Metadata as annotation 2018-06-27 12:37:18 +02:00
Dmitry Petrov d35a92a81d Generate accessor for private companion object 2018-06-22 16:53:07 +03:00
Mikhael Bogdanov 7c615eb7ab Minor. Reformat 2018-06-21 11:18:40 +02:00
Mikhail Zarechenskiy 7d5fdb660d Treat number with unsigned literal as UByte & UShort & UInt & ULong 2018-06-04 18:37:36 +03:00
Stanislav Erokhin 8f0b073c08 [NI] Prototype for SAM-conversion.
Supported:
- conversion in resolution parts. Also sam-with-receiver is supported automatically
- separate flag for kotlin function with java SAM as parameters

TODO:
- fix overload conflict error when function type is the same byte origin types is ordered
- consider case when parameter type is T, T <:> Runnable
- support vararg of Runnable

[NI] Turn off synthetic scope with SAM adapter functions if NI enabled
2018-06-04 12:21:56 +03:00
Ilya Gorbunov 1a290d0c73 Refactor: make JvmMemberSignature a sealed class
Use JvmMemberSignature.asString instead of toString
2018-06-01 06:43:48 +03:00