Commit Graph

456 Commits

Author SHA1 Message Date
Anton Bannykh ead8379c50 JS: add -Xmetadata-only flag for JS common code modules (KT-33142 fixed) 2019-09-27 19:12:03 +03:00
Dmitry Savvinov bfacc1a3c5 Introduce AbstractResolverForProject
Previously, ResolverForProjectImpl had multiple callbacks in
constructor. Some of those callbacks were used only to overcome module
visibility and provide an ability to inject IDE-specific logic into
compiler (ResolverForProject is in the 'compiler'-module)

This commit introduces abstract class which implements
environment-independent logic (previously, this logic had been stored in
ResolverForProjectImpl) with several abstract met hods (previously,
callbacks). Then, we provide few concrete implementations of
AbstractResolverForProject with clear semantics:

- IdeaResolverForProject: resolver used in IDE, where we have indices,
  oracles, multiple modules, etc.
- ResolverForSingleModuleProject: resolver for project with only one
  module, commonly used for CLI compiler/tests
- one anonymous implementation for MultimoduleTests

This refactoring achieves several things:
- now it is easier to see what kinds of ResolverForProject you might see
  in some particular environment (previously, one had to inspect all
  call-sites of constructor)
- we can easily add IDE-specific logic in IdeaResolverForProject without
  adding noisy callbacks (which most probably wouldn't have any other
  non-trivial implementations)
2019-09-24 17:05:05 +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
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
Mikhail Zarechenskiy 04e57f712e [NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new
 inference. Note that as for `SamConversionPerArgument`, this feature
 is enabled in the compiler and not in the IDE to avoid breaking code
 for those users that already enabled new inference in the compiler
2019-08-07 15:58:36 +03:00
Dmitry Savvinov 2b4d70fcf0 [Resolve] Rewrite how built-ins are created
Under COMPOSITE mode we don't have a globally known way to create
built-ins, instead, we have to create them on per-module basis.

So, in this commit we:

1. Use builtInsProvider: (ModuleInfo) -> KotlinBuiltIns instead of
precomputed builtIns instance, in order to be able to calculate
builtIns on per-module basis

2. Introduce new entity, called BuiltInsCache, which, roughly
speaking, is a map of form ModuleInfo -> KotlinBuiltIns, to prevent
creation of multiple builtInsInstances
NB. Actually, it's of form BuiltInsCacheKey -> KotlinBuiltIns, because
we shouldn't create new builtIns for each module. Also, currently,
each platform has its own BuiltInsCacheKey implementation, because
parameters by which built-ins are created, are a bit different across
different platforms. Ideally, we should eliminate those differences
and they use one concrete implementation as a key.
2019-07-30 12:41:40 +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
Ilya Chernikov 0072f8c265 Improve JSR-223 engine diagnostics
also abstract invoke wrapper creation
2019-07-26 08:55:14 +02:00
Victor Petukhov e25b315319 Introduce -Xpolymorphic-signature compiler flag as more priority than -XXLanguage:+PolymorphicSignature 2019-07-26 09:01:25 +03:00
Victor Petukhov 944ee8fcd5 Introduce -Xinline-classes compiler flag as more priority than -XXLanguage:+InlineClasses 2019-07-26 09:01:25 +03:00
Ilya Chernikov 9ae0ff03fa Improve script and REPL result handling:
- implement error result
- refactor other result classes
- implement handling in the script evaluation extension - also restores
  previous script error reporting functionality
- add possibility to customize result fileds in script and REPL
- refactor result calculation in the backend: cleanup, rename (since
  it is not only about REPL now)
2019-07-11 15:50:26 +02:00
Andrey Uskov e079615cdf Add possibility to edit target platform for non-HMPP projects in order to keep ability to edit target platform for IDEA-based projects 2019-07-02 22:46:48 +03:00
Andrey Uskov 9fc60be9d8 Fix serialization of facet settings in order to read properly
settings of native platforms
2019-07-02 22:46:47 +03:00
Nikolay Krasko 12bb1a5bd1 Make invalidateOnOOCB explicit in ResolverForProjectImpl and remove usage in tests 2019-07-02 13:45:35 +03: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
Vyacheslav Gerasimov fc68bb46dc Build: Move compiler.xml extensions to cli-common 2019-06-27 17:56:51 +03:00
Roman Artemev cc46657c99 [JS IR BE] Fix misprint 2019-06-14 18:40:59 +03:00
Andrey Uskov c0bf5a6566 Import of middle HMPP target platforms is supported 2019-06-13 18:30:01 +03:00
Dmitry Savvinov 174ef56991 [Expect/Actual] Remove PlatformExpectedAnnotator 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
Svyatoslav Kuzmich cd651be461 [JS IR BE] Migrate JS BE to common klib utils 2019-06-05 11:15:45 +03: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 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 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 4116815a8d [Misc] Provide meaningful debugName for StorageManager everywhere 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 c97138c0eb [Injection] Pull languageVersionSettings injection to 'configureModule' 2019-05-28 13:08:08 +03:00
Dmitry Savvinov 1606b3bf23 [Platform API] Make 'ModuleInfo.platform' non-nullable 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
Ilya Chernikov ea068e483c Implement JSR-223 functionality on top of the "new" REPL 2019-05-25 10:10:29 +02:00
Ilya Chernikov 46915df56f Implement "legacy" REPL wrappers on top of the "new" scripting infrastructure 2019-05-25 10:10:29 +02:00
Ilya Chernikov 89006f16cd Prepare scripting infrastructure for REPL:
- refactor script compiler to simplify extending it for repl
- add repl snippet compilation functions to the new scripting compiler
- extract util functions into appropriate files
- extract repl part into separate class
- extract bridge definition and related definitions into separate file
2019-05-25 10:10:28 +02:00
Mikhail Glukhikh f4fdc66a34 Introduce experimental FIR compiler #KT-31265 Fixed
This commit also includes several FIR2IR fixes which helps FIR compiler
to produce normal results
2019-05-23 14:02:06 +03:00
Alexander Udalov d340f6dc62 Minor, simplify code in parseCommandLineArguments 2019-05-22 08:48:37 +02:00
Svyatoslav Kuzmich b07690fccf Phaser: Implement dumper and verifier as general actions 2019-05-14 16:23:43 +03:00
Alexander Udalov 5aae832c5f Minor, update doc on -Xsanitize-parentheses
The ASM issue with parentheses was fixed in
https://gitlab.ow2.org/asm/asm/commit/02f00c4a82d9252b34d08dad47c540309fda3b7e

 #KT-29475
2019-04-30 13:15:29 +02:00
Andrey Uskov 998a24414a Improved parsing of internal compiler arguments with boolean state in
case when the argument is listed twice in the list of command line
arguments. The last value will be used.
#KT-27181 Fixed
2019-04-29 19:48:01 +03:00
Dmitry Gridin 3e74e875e8 Add a colon check in LanguageSettingsParser 2019-04-25 19:47:39 +07:00
Dmitry Gridin 37c856290f Fix minor compile warnings 2019-04-25 19:47:39 +07:00
Dmitry Gridin c41b98f5b9 Replace SystemInfo.isJavaVersionAtLeast("1.7") with SystemInfo.isJavaVersionAtLeast(1, 7, 0) 2019-04-25 19:47:38 +07:00
Svyatoslav Kuzmich bb3b9a935f Command line interface 2019-04-23 23:19:12 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Ilya Chernikov 64c3bcd9ab Drop refactored-out frontend.script module 2019-04-17 22:03:58 +02:00
Ilya Chernikov a65dafc37d Move scripting support classes to the scripting compiler impl module 2019-04-17 22:03:58 +02:00
Mikhail Zarechenskiy 705a8a2234 [NI] Disable SAM-conversions for Kotlin functions by default
#KT-30661 Fixed
2019-04-17 01:40:54 +03:00
LepilkinaElena 21fe5ac415 Fix parser for linkerOpts/compilerOpts (KT-29970) (#2219) 2019-03-29 20:13:23 +03:00
Alexander Udalov 4cb5a4fb6d Fix misc typos in IR backends 2019-03-28 14:26:09 +01:00
Alexey Tsvetkov 0687b8eac3 Add argument to allow running compiler without sources
`-Xbuild-file` argument allows the compiler to run without
passing any Kotlin source file in arguments.
We have been using this property in
Kotlin Gradle plugin for a few important cases:
1. incremental compilation (to update caches when there are only removed files);
2. for KAPT (Kotlin sources don't make sense in context
of running APs).

We want to stop using `-Xbuild-file` in Kotlin Gradle plugin,
and avoid breaking the Gradle plugin or IC in other build-systems.

This change adds an argument to explicitly run
the compiler without specifying any Kotlin source file.
2019-03-25 16:39:47 +03:00