Commit Graph

2810 Commits

Author SHA1 Message Date
Mikhael Bogdanov
2ed0cb2a89 Support type annotations
#KT-35843 Fixed
2020-01-09 14:00:11 +01:00
Mikhail Zarechenskiy
e078282767 Fix ambiguity between Java and Kotlin SAM candidates
Because of incorrect flag we generated synthetic SAM candidates and got ambiguity when feature `SamConversionPerArgument` was enabled (Gradle case) because candidates for Java were duplicated

 #KT-35579 Fixed
2019-12-23 12:22:20 +03:00
Denis Zharkov
e8131d6e30 Choose Java field during overload resolution with a pure Kotlin property
^KT-31244 Fixed
2019-12-19 10:53:31 +03:00
Victor Petukhov
07269661b4 NI: Allow to resolve to functions with SAM conversion and passing array without spread as vararg (with warning)
^KT-35224 Fixed
2019-12-12 23:46:16 +03:00
Ilya Chernikov
7dd9ed7e38 [NI] Fix loosing type annotations on extension functions
#KT-32138 fixed
2019-11-29 13:44:41 +01:00
Mikhail Zarechenskiy
eb73650209 Fix race in IDE: inject proper storage manager for type parameters
With NO_LOCKS strategy we can easily end up in a situation when
 constraint system for a generic call is built incorrectly,
 producing flaky errors (or don't produce errors at all)

 Now proper storage manager is injected for all cases except:
 - IR
 - Codegen
 - Serialization plugin
 - Fake local objects

 Most likely, NO_LOCKS strategy for these cases is fine as at that point
 the compiler works in one thread

 #KT-34786 Fixed
2019-11-26 10:52:45 +03:00
Alexander Udalov
57a674e9e6 Make fast class files reading mode default in compiler tests
This makes sense because this mode is the default in the production
compiler. Forgetting to enable it where necessary led to different
bizarre test failures, see for example changes around 3fee84b966 and
KT-34826
2019-11-11 15:40:49 +01:00
Alexander Udalov
5c89f2fa54 Support KClass.qualifiedName in stdlib-only reflection implementation
#KT-34586 Fixed
2019-10-29 15:51:25 +01:00
Alexander Udalov
c164745301 Support KClass.simpleName in stdlib-only reflection implementation
#KT-33646 Fixed
2019-10-29 15:51:21 +01:00
Alexander Udalov
df4ab4ed81 Add JVM bytecode target version 13
#KT-34119 Fixed
2019-10-29 12:54:24 +01:00
Mikhael Bogdanov
c78dbaf6b3 Initializer default values in 'tailrec' method in proper order
#KT-31540 Fixed
2019-10-17 13:06:36 +02:00
Yan Zhulanow
a4c8ccee06 kapt: Fix compilation in 'compile' running mode (KT-33800) 2019-10-08 19:13:57 +09:00
Pavel Kirpichenkov
b7e5d9faae Update annotation rendering in diagnostics
Disable annotation rendering in default type and descriptor renderers.
Preserve annotations in Android and Serialization plugins.
Update error texts in ide tests.
Nullability annotations in Java descriptors are rendered with context-dependent renderer.

#KT-20258 Fixed
2019-10-04 11:18:45 +03:00
Alexander Udalov
6ef434a711 JVM IR: add -Xir-check-local-names to check names for consistency
Since KotlinTypeMapper is no longer used in the JVM IR backend, we need
not run CodegenBinding.initTrace and check that names of local entities
are exactly equal to local names computed by that algorithm.

However, it's still useful as an opt-in flag, to discover issues where
unwanted elements take part in the naming (such as temporary IR
variables, see for example cb2e68fece). So we introduce a new command
line argument -Xir-check-local-names which, when the IR backend is used
(via -Xuse-ir), launches the name computation algorithm from the old
backend and then compares that the names are exactly equal to the names
computed by the IR backend in InventNamesForLocalClasses.
2019-09-18 17:55:42 +02:00
Matthew Gharrity
a1f4a4572a Check cancelation in KotlinJavaPsiFacade.findPackage()
This may help with some UI freezes caused by KT-33394, although
it does not fix the underlying performance problem.
2019-09-16 10:58:58 -07:00
Pavel Kirpichenkov
0a1b3a8455 Clearify diagnostic messages that involve internal visibilities
KT-7354 Fixed

Visibility.displayText is deprecated with warning.
Diagnostics for java visibilities changed.
2019-09-16 19:00:43 +03:00
Alexander Udalov
8efbcc5350 Do not use KotlinTypeMapper when generating JVM assert inline intrinsics 2019-09-11 23:33:10 +02:00
Nikolay Krasko
0ae9240e5f Remove 182 and AS33 from build scripts
#KT-33536 Fixed
2019-08-30 12:14:50 +03:00
Alexander Udalov
312205f376 Prohibit synchronized methods on interface members
#KT-9310 Fixed
2019-08-22 18:04:00 +02:00
Dmitry Savvinov
0065236bde Move default implementation of TargetPlatform.platformName to leaf classes
Otherwise, we have a static initialization loop, leading to null-leaks

Removing default interface method indeed disconnects the loop, as per JVM
Specification, "5.5 Initialization".

See KT-33245 for detailed explanations

^KT-33245 Fixed
2019-08-12 13:06:51 +03:00
Dmitry Savvinov
b48218e722 [Resolve] Make ResolversForModule less static
As consequence, remove IdePlatformKindTooling.resolverForModule, because
it became more than just field, and it duplicates similar API in
IdePlatformKindResolution anyways
2019-07-30 12:41:40 +03:00
Denis Zharkov
5c2c7e7776 [Invariant fix] Avoid re-resolving declared descriptors in lazy member scopes
It becomes necessary after scopes/types refinement
Without it being applied the code might fail with slice-rewrite errors

KT-32841
2019-07-30 12:41:38 +03:00
Dmitry Savvinov
04717b57c9 [API Usage] Support refinement for Java classes' scope
Also, we should skip supertypes refinement for additional
    built-in members scope
2019-07-30 12:41:37 +03:00
Alexander Udalov
f38e4d618e Support Array::class literal, forbid Array<X>::class on non-JVM
#KT-31230 Fixed
2019-07-16 15:57:26 +02:00
Steven Schäfer
e7a5e5b4a0 JVM_IR: Handle annotation KClass fields in external declarations 2019-07-01 16:16:23 +02:00
Mikhail Zarechenskiy
c2cf4aa2b5 [NI] Move ability to convert standalone SAM-argument under the feature
If new inference is enabled only for IDE analysis, then this feature
 will be disabled to reduce difference between new and old inference,
 but if new inference is enabled in the compiler, then this feature
 will be enabled too to preserve behavior of new inference for
 compilation

 #KT-32175 Fixed
 #KT-32143 Fixed
 #KT-32123 Fixed
 #KT-32230 Fixed
2019-07-01 12:53:33 +03:00
Dmitry Savvinov
0915f0c78a [Expect/Actual] Let DI instantiate ExpectedActualDeclarationChecker
Inject it instead of calling constructor manually and passing instance
directly into the container. This allows to accept some components in
constructor of ExpectedActualDeclarationChecker
2019-06-10 13:34:27 +03:00
Mikhail Zarechenskiy
787a8bb9bd Revert "[NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI"
This reverts commit 7c4101e21c.

 #KT-31866 Fixed
 #KT-31868 Fixed
 #EA-125401 Fixed
 #KT-25290 Open
2019-06-07 12:31:38 +03:00
Dmitry Savvinov
dca23f871c Allow to force-require syntetic SAM-adapters even in NI
This is needed for some IDE clients, particularly, completion: even
though presenting only non-converted member (e.g., 'foo(Consumer<Int>')
is nominally OK, as resolution with NI is smart enough to accept 'foo { }'
for such a call, it is inconvenient for users (for example, hitting
enter would insert round brackets instead of a figure brackets)

This commit adds very-very narrow API (borderline hacky) in
JavaSyntheticScopes, to allow clients explicitly ask for a scopes with
force-enabled synthetic conversions. It fixes several tests, which had
started to fail after corresponding commit about NI and SAM-adapters
(fe5976d7f4), e.g.:
- Java8BasicCompletionTestGenerated.testCollectionMethods
- Java8BasicCompletionTestGenerated.testStreamMethods
- JvmBasicCompletionTestGenerated$Common$StaticMembers.testJavaStaticMethods
- JvmBasicCompletionTestGenerated$Java.testSAMAdaptersStatic
- JvmWithLibBasicCompletionTestGenerated.testSamAdapter
- JvmWithLibBasicCompletionTestGenerated.testSamAdapterAndGenerics

Note that changes are made in ReferenceVariantsHelper, which is used by
several other clients in IDE. Presumably, those changes are needed for
them too.
2019-06-03 10:46:53 +03:00
Alexander Udalov
e9b50157da Try loading PSI from descriptor in OtherOrigin constructor
To simplify several call sites
2019-05-29 10:23:19 +02:00
Dmitriy Novozhilov
7c4101e21c [NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI 2019-05-29 10:35:46 +03:00
Mikhail Zarechenskiy
848640253a Revert "[NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI"
This reverts commit f20ec3e0a6.
2019-05-29 01:31:28 +03:00
Dmitry Savvinov
893ac735bc Convert property initializer to getter in
JvmPlatforms.unspecifiedJvmPlatform

This unties static initialization loop which lead to NCDFE and other
issues.
2019-05-28 16:03:05 +03:00
Dmitry Savvinov
8997fa52df Introduce unspecifiedJvmPlatform for clients without jvmTarget
Previously, a lot of clients used JvmPlatform as platform-marker,
without thinking about jvmTarget.

For the sake of migration, this commits introduced so-called
UnspecifiedJvmPlatform, which can be used for a time being, but
generally, all usages should be removed in  future.
2019-05-28 13:08:09 +03:00
Dmitry Savvinov
1a11eaa4c6 Overload equals for JdkPlatform 2019-05-28 13:08:09 +03:00
Dmitry Savvinov
9d0f518d62 Rename PlatformDependentCompilerServices -> PlatformDependentAnalyzerServices 2019-05-28 13:08:09 +03:00
Dmitry Savvinov
2caa1c3dd6 [Compatibility] Restore old TargetPlatform and subtypes for compatibility 2019-05-28 13:08:08 +03:00
Dmitry Savvinov
602f642018 [Injection] Make component containers composition more granular and flexible
Previously, containers set-up was performed by calls to static functions
like 'createContainerForLazyResolve', which would set-up whole container
from scratch.

This has several issues:
- complicates code re-use and encourages copy-paste of one and the same
set-up logic
- complicates composition of multiplatform containers (because each
set-up method relies on the fact that it should take an empty
container and compose it completely)

The idea of this commit is to split set-up methods into smaller ones,
with finer areas of responsibility, which allows to re-use them
in various scenarios (and, in particularly motivating composition
of multiplatform container)
2019-05-28 13:08:08 +03:00
Dmitry Savvinov
72e28d37fc [Injection] Introduce PlatformSpecificExtensions and PlatformExtensionsClashResolver
This commit introduces the ability to register a PlatformExtensionClashResolver
in a container. Each PlatformExtensionClashResolver has a corresponding
PlatformSpecificExtensions.

If, during container composition, several instances of
PlatformSpecificExtensions were registred, instead of throwing
InvalidCardinalityException, corresponding PlatformExtensionClashResolver
will be asked to resolve clash.

This allows to make injection more composable and less coupled across
different contributors of service, providing a basis for such motivating
cases as composing containers with both JS and JVM services (for analysis
of multiplatform modules).
Previously, that would be impossible:
a) JS would inject default instances for some services which would clash
with non-default JVM services (like SyntheticScopes)
b) Also, there are a very few services for which *both* platforms provide
non-default implementations, so they should be merged manually on
case-by-case basis (e.g., IdentifierChecker)
2019-05-28 13:08:08 +03:00
Dmitry Savvinov
b631e89ea7 [Injection] Annotate default services with @DefaultImplementation 2019-05-28 13:08:08 +03:00
Dmitry Savvinov
c97138c0eb [Injection] Pull languageVersionSettings injection to 'configureModule' 2019-05-28 13:08:08 +03:00
Dmitry Savvinov
b81b388b33 [Injection] Minor: inline createContainerForTopDownAnalyzerForJvm
Essentially, this function was used solely for setting
'useBuiltInsProvider' to 'true'; otherwise it were just delegating to
createContainerForLazyResolveWithJava, which were just increasing the
noise.
2019-05-28 13:08:07 +03:00
Dmitry Savvinov
70be224f0f [Injection] Minor: inline configureJavaTopDownAnalysis
It was used called only once, and hasn't provided any useful
abstraction.

Actually, this "cosmetic" refactoring makes similarities with other
platform-specific container set-ups cleare, which allows to make further
generalizations and simplifications.
2019-05-28 13:08:07 +03:00
Dmitry Savvinov
b54982a29a [Injection] Minor: reformat injection.kt 2019-05-28 13:08:07 +03:00
Dmitry Savvinov
d5fbe59a3e [Platform API] Introduce fundamental abstraction of Platform
This is a large commit, which introduces general API for working with
abstraction of Platform.

- Add new abstraction to 'core' - SimplePlatform - which represents
exactly one platform
  - Clients are strongly prohibited to create instances of SimplePlatform
  by hand, instead, corresponding *Platforms abstraction should be used
  (e.g. JvmPlatforms, JsPlatforms, KonanPlatforms)

- Move TargetPlatform to 'core', it represents now a collection of
SimplePlatforms
  - Clients are strongly encouraged to use TargetPlatform
    (not SimplePlatform) in API, to enforce checks for multiplatform

- Provide a helper-extensions to work with TargetPlatform
(in particular, for getting a specific component platform)

- Remove MultiTargetPlatform in favour of TargetPlatform
  - Notably, this commit leaves another widely used duplicated abstraction,
    namely, IdePlatform. For the sake sanity, removal of IdePlatform is
    extracted in the separate commit.
2019-05-28 13:08:07 +03:00
Dmitry Savvinov
451d14e504 [Platform API] Minor: move some classes to separate files 2019-05-28 13:08:07 +03:00
Dmitry Savvinov
f2a0a809f1 [Platform API] Split TargetPlatform into lightweight TargetPlatform and CompilerServices
This decouples simple data (TargetPlatform) from other subsystem-specific
logic (like default imports, built-ins, etc.).

Aside from purely aesthetic improvements, it also makes it easier
to move 'TargetPlatform' into core (see next commits)
2019-05-28 13:08:06 +03:00
Dmitry Savvinov
83914614b9 [Platform API] Clean-up some usages of Platform
Mostly unused imports. Also, in some places,
TargetPlatform/MultiTargetPlatform were just passed around without
actually using (e.g. in deserialization)
2019-05-28 13:08:06 +03:00
Dmitry Savvinov
520e871280 Rename *AnalyzerFacade to *ResolverForModuleFactory to prevent confusion with other similar names 2019-05-28 13:08:06 +03:00
Dmitriy Novozhilov
f20ec3e0a6 [NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI
There is added a new service named `SubstitutingScopeProvider`, that
  provides factory that creates captured types and approximator for them.
  In OI they are the same as before commit, for NI they are empty, because
  that approximation interferes with NI algorithm

That service is injected into function descriptors and property descriptors
  and used for creating `SubstitutingScope` with correct services

Also there is changed time when we approximate captured types in NI
  (after all call checkers)

#KT-25290 Fixed
2019-05-28 11:18:33 +03:00