Commit Graph

24779 Commits

Author SHA1 Message Date
Dmitry Savvinov b631e89ea7 [Injection] Annotate default services with @DefaultImplementation 2019-05-28 13:08:08 +03:00
Dmitry Savvinov d80eba31be [Injection] Discriminate default instances during clashes resolution
The idea is to try to resolve the dependency without considering default
instances first.

This makes containers more composable, e.g., it is now possible to put
several containers together as long as all except one provide default
implemenetation for some particular service (non-default implementation
will be automatically chosen, and all defaults will be discarded).
2019-05-28 13:08:08 +03:00
Dmitry Savvinov 398d715fc6 [Injection] Minor: remove explicit injection of ExpressionTypingServices
They will be injected automatically anyways
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 89603327c5 [Injection] Minor: inline createLazyResolveSession 2019-05-28 13:08:08 +03:00
Dmitry Savvinov eb155dcf3b [Injection] Minor: inline configureModule overload without trace 2019-05-28 13:08:07 +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 1606b3bf23 [Platform API] Make 'ModuleInfo.platform' non-nullable 2019-05-28 13:08:07 +03:00
Dmitry Savvinov 2ebdd7d2b9 Add platform suffix to the name of created module in tests
This is needed because platform of the module is determined by the
suffix after last '-' in 'createModule', and for string 'test-module'
that would be 'module', which obviously doesn't make any sense.

Howwever, due to how MultiTargetPlatform was implemented, it was
possible to create platform with such name, and everything was fine
as long as no one actually tried to switch on such a malformed
"platform".

After switching to more strict TargetPlatform representation, some tests
that had been trying to create platforms with such names started failing.

Seems that it was purely a mistake introduced in the
af1264a46d, so this commit fixes it by
specifying proper module name
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 bf51a402b9 Remove deprecated method 2019-05-28 13:08:06 +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 7e1afdcd28 Remove internal API method which was deprecated in 1.3.0 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
Alexander Udalov 082c337faa Support fake Java property overrides in function equality in bridges
A synthetic property descriptor created for `B.value` (see the added
test) should not be equal to the normal descriptor created by the fake
override construction algorithm. Otherwise we can't reach this synthetic
non-abstract descriptor when building bridges in `C`, which results in
exception.

 #KT-31367 Fixed
2019-05-28 11:50:13 +02:00
Dmitriy Novozhilov 910177ab17 [NI] Add checking @NotNull parameters for candidates 2019-05-28 11:18:33 +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
Mikhail Glukhikh 2db8409d85 FIR: introduce & resolve spread named arguments #KT-31575 Fixed 2019-05-28 10:20:42 +03:00
Mikhail Glukhikh 806d2d628c FIR Java: correctly handle overridden Kotlin properties in use-site scope 2019-05-28 10:20:41 +03:00
Mikhail Glukhikh 56435fa283 FIR Java: add default constructors 2019-05-28 10:20:40 +03:00
Mikhail Glukhikh d0404b2c2a FIR resolve: check number of parameters when handling Java accessors 2019-05-28 10:20:38 +03:00
Mikhail Glukhikh eaf7e46da3 FIR resolve bench: count implicit built-in type refs as resolved 2019-05-28 10:20:37 +03:00
Mikhail Glukhikh 459dcb4f57 FIR resolve: set implicit Unit type for block without result expression
This fixes most of "implicit error types"
2019-05-28 10:20:36 +03:00
Mikhail Glukhikh d2bdbd8978 FIR resolve: record & check implicit extension receiver type properly 2019-05-28 10:20:35 +03:00
Mikhail Glukhikh d9d582b226 FIR tower resolve: add level with implicit extension receiver 2019-05-28 10:20:33 +03:00
Mikhail Glukhikh 45b0f5a0ca Add FIR resolve test (call extension from extension) 2019-05-28 10:20:32 +03:00
Mikhail Glukhikh bc336650ff More top-level FIR resolve tests (map, with) 2019-05-28 10:20:31 +03:00
Simon Ogorodnik 94dca1d467 Suspend resolution sequence on first inapplicability report 2019-05-28 10:20:29 +03:00
Mikhail Glukhikh cb76ea5d14 FIR resolve: do not launch overload conflict resolve for erroneous 2019-05-28 10:20:28 +03:00
Mikhail Glukhikh 4d145db9f7 FIR resolve (by semoro): support correct type inference for generic args
This commit includes additional test and fixes e.g.
resolve of listOf() + listOf()
2019-05-28 10:19:12 +03:00
Mikhail Glukhikh 3cede7e827 Make FIR cone flexible type data class to improve constraint comparison 2019-05-28 10:19:08 +03:00
Mikhail Glukhikh 0d35c68f88 Use abstract 'createErrorType' in TypeApproximator to fix FIR assertion
NB: each type system should use its own error types
2019-05-28 10:18:36 +03:00
Simon Ogorodnik 36ab325394 Abstract FIR modularized tests 2019-05-28 10:18:35 +03:00
Simon Ogorodnik 60a73ca13f Report percents in FirResolveBench 2019-05-28 10:18:34 +03:00
Simon Ogorodnik d3f00280e9 Disable data class copy function body in raw FIR
After this commit we require 'copy' body generation in FIR2IR converter
2019-05-28 10:18:00 +03:00
Simon Ogorodnik a849cc7da4 Store type for already resolved FIR references properly 2019-05-28 10:17:59 +03:00
Simon Ogorodnik 58873b2d7b FIR resolve: set setter value-parameter type properly 2019-05-28 10:17:57 +03:00
Simon Ogorodnik 38d3438101 [FIR] Support withNullability for captured type 2019-05-28 10:17:56 +03:00
Mikhail Glukhikh 05e4539019 Set resolved type for lambdas properly during FIR resolve
Partially done by semoro
2019-05-28 10:17:31 +03:00
Mikhail Glukhikh 963ed44ce1 FIR: fix exception in ConeKotlinType.returnType 2019-05-28 10:17:25 +03:00
Mikhail Glukhikh 5c96fa0844 Raw FIR: set enum entry types to kotlin.Enum to avoid their resolve 2019-05-28 10:17:23 +03:00
Mikhail Glukhikh 6589fbbfbb Raw FIR: set val setter to null instead of default one 2019-05-28 10:17:22 +03:00
Mikhail Glukhikh 0aaf8c7689 Fix FIR Java enhancement of java.util.Map & similar supertypes 2019-05-28 10:17:21 +03:00
Simon Ogorodnik cef108a5ae FIR: implement qualifier resolver 2019-05-28 10:17:05 +03:00
Jiaxiang Chen d3cc0e6ce9 JVM_IR: Optimize disjunction condition with intrinsic function call. 2019-05-28 08:48:43 +02:00
pyos 6d19eb1853 JVM_IR: sidestep defective getMethodAsmFlags when inlining lambdas
It uses isStaticMethod to determine whether to set ACC_STATIC, which is
not correct (see PR #2341). This results in using incorrectly typed
opcodes (as all arguments are shifted by 1) when modifying the inlined
lambda's bytecode. For example, in the test added by this commit, these
opcodes are inserted to spill the stack into locals before calling
another inline function.

Because getMethodAsmFlags is used by the non-IR backend (see PR #2341
again for why changing stuff might not be a good idea), the proposed
solution is to ditch it completely and override generateLambdaBody in
IrExpressionLambdaImpl to use FunctionCodegen's IR-based flag
computation logic.
2019-05-28 08:38:16 +02:00