Commit Graph

687 Commits

Author SHA1 Message Date
Dmitriy Novozhilov ba272101f2 Check for ESReceiver for contracts with is check 2020-04-15 11:12:56 +03:00
Mikhail Zarechenskiy 54497d11ac Move SyntheticMemberDescriptor.kt to core
This is a first part of unification SAM constructors for all platforms
2020-04-15 02:06:32 +03:00
Ilya Chernikov acc5633811 [NI] Fix inference of lambda with receiver when wrapped...
in when/if or another lambda.
#KT-37419 fixed
2020-04-13 14:50:49 +02:00
Mikhail Zarechenskiy a7b959b88b Fix delegated property resolve with intermediate ID provideDelegate
#KT-37406 Fixed
2020-04-09 13:34:29 +03:00
Dmitry Petrov d1c5a42124 KT-36024 Generate adapted callable references as lambdas
Make sure both JVM and JVM_IR use the same information to determine
whether a callable reference requires argument adaptation.
2020-04-08 19:02:33 +02:00
Victor Petukhov 164f25937f NI: take into account an extension function annotation during CST calculation 2020-04-02 15:28:35 +03:00
Victor Petukhov f8d72f5dd9 NI: improve lambdas completion – look at all postponed arguments during resolution lambdas by additional conditions
^KT-36819 Fixed
^KT-36069 Fixed
2020-04-02 15:28:11 +03:00
Pavel Kirpichenkov a416fde814 [NI] Move abstract class instantiation check to call checkers
This way the check works for callable reference arguments.
Also candidate applicability during resolution does not change compared to the old inference.
^KT-37530 Fixed
2020-03-31 12:04:01 +03:00
Alexander Udalov 92534eadaa Remove dependency of 'resolution' on 'deserialization'
Replace it with a dependency on 'descriptors'.

Move the existing marker interface ContractProvider to 'descriptors',
and create a new marker interface DeserializedDescriptor.
2020-03-28 21:30:07 +01:00
Alexander Udalov 7bb77e5672 Move JS binary version utilities to 'js.config'
This allows to replace dependency of 'util' on 'deserialization' with
dependency on 'descriptors'.
2020-03-28 21:30:06 +01:00
Pavel Kirpichenkov e39b69839b [NI] Make constraint check for type variables with complex dependency
Additional check for trivial constraints is needed to make lambda
analysis before outer variable fixation to Nothing(?)

^KT-37627 Fixed
2020-03-26 17:06:37 +03:00
Pavel Kirpichenkov 568b21e31c minor: refactor cast into context operation 2020-03-26 17:06:37 +03:00
Pavel Kirpichenkov adf3351a8b [NI] Don't skip constraints with projections during variable fixation
Those constraints are only restored for variable fixation stage because of the
influence on pefrormance.

^KT-37650 Fixed
^KT-37380 Fixed
2020-03-24 16:13:49 +03:00
Pavel Kirpichenkov dc18c62dbc [NI] Filter out type variable from its dependencies
Don't take into account complex variable dependency on itself when determining fixation status.
^KT-37621 Fixed
2020-03-24 12:49:18 +03:00
Mikhail Zarechenskiy ec4d9d2f1f [NI] Prefer between two complex variables one with proper lower bounds
This reverts commit d4d35bb766.
2020-03-24 11:13:55 +03:00
Ilya Chernikov 44ffed9590 Approximate only types substituted with captured types
properly fixes #KT-37389
#KT-37389 fixed
#KT-37644 fixed
2020-03-23 22:58:45 +01:00
Mikhail Zarechenskiy 191fb02bf6 [NI] Consider intersection type with number type as Nothing
Currently, only for "in": In<in Int & A> == In<in Nothing> == In<*>

 #KT-37302 Fixed
2020-03-23 16:39:21 +03:00
Mikhail Zarechenskiy 72ce4eb5ee Minor, replace fields with getters to avoid leaking "this" inspection 2020-03-23 16:39:19 +03:00
Mikhail Zarechenskiy d4d35bb766 Revert "[NI] Prefer between two complex variables one with proper lower bounds"
This reverts commit ced8a92629.
2020-03-22 17:16:22 +03:00
Mikhail Zarechenskiy ced8a92629 [NI] Prefer between two complex variables one with proper lower bounds
#KT-37554 Fixed
2020-03-20 15:44:53 +03:00
Victor Petukhov 3b892fe31e NI: exclude reporting of an unsafe call diagnostic for implicit invoke after safe call in cases when invoke has type parameters (make NI and OI consistent)
^KT-37579 Fixed
2020-03-19 19:27:25 +03:00
Victor Petukhov 81385b73b7 NI: limit cache size for approximated types during incorporation 2020-03-19 12:47:48 +03:00
Victor Petukhov ea59ea8aa2 NI: avoid creating useless captured types during incorporation
^KT-37546 Fixed
2020-03-19 12:47:03 +03:00
Ilya Chernikov da1009eb2c Avoid type approximation on generating equality constraints
#KT-37389 fixed
2020-03-18 18:34:09 +01:00
Ilya Chernikov 950ab01596 Avoid substitution and type approximation for simple calls
#KT-37392 fixed
2020-03-18 18:34:09 +01:00
Vladimir Dolzhenko 87242b419a Improvements in KotlinCopyPasteReferenceProcessor
reduced scope of nonBlockingRead to avoid long rerun of it
used smart pointers to keep valid elements over changes
moved back to non-modal progress

Relates to #KT-37414
2020-03-12 22:42:58 +01:00
Victor Petukhov b1c4b5f51b NI: Analyze lambdas which are return arguments of another lambda
^KT-36044 Fixed
2020-03-12 23:29:09 +03:00
Ilya Chernikov 3cbfdd19f5 Optimize constraints simplification
simplify only when affecting changes are detected
2020-03-12 08:02:46 +01:00
Ilya Chernikov c2b866fe7a Reduce number of constraints simplifications
assuming that MutableVariableWithConstraints is constructed either
with no initial constraints or already from simplified list
2020-03-12 08:02:46 +01:00
Ilya Chernikov 84a0e39956 Skip duplicates removal on constraints simplification
It is already coveren on addition. Speeds up inference a bit.
2020-03-12 08:02:46 +01:00
Ilya Chernikov 4538e212db Optimize hot addSubTypeConstraintAndIncorporateIt function
reduce number of allocations, optimize for cases with small number
of possible new constraints
2020-03-12 08:02:45 +01:00
Ilya Chernikov 357ceeae19 Avoid unnecessary freshTypeConstructor() calls 2020-03-12 08:02:45 +01:00
Ilya Chernikov 54f10a709a Cache isProperType calculations in the constraint system
avoid expensive calculations with type.contains
2020-03-12 08:02:45 +01:00
Ilya Chernikov 70c89a28e1 Stop subtyping constraint search if equality constraints for...
all not fixed type vars are found
#KT-35626 fixed
2020-03-12 08:02:45 +01:00
Alexander Udalov 795d6ab407 Migrate UseExperimental->OptIn in project sources 2020-03-10 12:07:14 +01:00
Victor Petukhov 92a0ddfe71 NI: discard def not null types if they appear in return positions, in inv or in variance
^KT-37343 Fixed
2020-03-08 19:00:27 +03:00
Dmitriy Novozhilov 643d7be12d [FIR] Add base class for PostponedResolvedAtomMarker to FIR 2020-03-06 18:10:51 +03:00
Pavel Kirpichenkov dc42b20ae3 [NI] Use alternative to intersection type in public declarations
The new inference uses inferred intersection types normally, unlike the old inference.
However, intersection types in public declarations are approximated to supertype, which
potentially may give a less presice type, then it would be with the OI.
For non-related T1, T2 the NI approximates {T1 & T2} to Any in public declarations,
and if the OI was inferring T1 instead of the intersection type, it may lead to
less precise declaration type and related errors.

The solution is to remember an alternative for an intersection type when present.
Before approximation the alternative replaces the intersection type.

^KT-36249 Fixed
2020-03-05 20:20:47 +03:00
Dmitry Petrov 4038c758ca KT-37131 Record default arguments in argument adaptation
Also, don't adapt argument when expected type is base reflection type
(KCallable<T>, etc), since such types don't contain parameter types.
2020-03-05 19:32:39 +03:00
Pavel Kirpichenkov 23ed6c4a1f [NI] Narrow nullability constraint check in incorporator
This commit is a hotfix rather then proper solution.
The source of the issue is that currently type variable fixation result
may change due to fixation order alteration for variables with the same priority.
For instance, having variables V1, V2, and proper types Type1, Type2, such that:
V1 <: Type1
V1 <: V2
Type2 <: V2
both variables will be fixed either to Type1, if V1 will be fixed first,
or to Type2 otherwise.

Since this limitation cannot be easily overcome, the taken approach is to remove
incedental constraint added after 2d5a0546 by restricting nullability constraint check
to `Nothing?` constraints only, thus postponing problematic variable fixation.
To clearify, additional constraint is correct and should cause no harm (in ideal world),
but currently its presence changes fixation order.
So without the restriction the previously used constraint from fixed outer variable
is no longer available by the time problematic variable type is being selected.

^KT-37043 Fixed
2020-03-03 12:57:25 +03:00
Victor Petukhov 51749b9747 NI: don't try to infer visible lambda parameters, if there is single one – extension parameter
^KT-37038 Fixed
2020-03-02 20:28:59 +03:00
Mikhail Zarechenskiy 14f7529c1b [NI] Reanalyze coroutine-block if there is inapplicable call
It's not clear how one should rollback _all_ resolution results if
 there is inapplicable call. Ideally, such calls should not be available
 in coroutine block but for now, to have backward compatibility, we'll
 just reanalyze coroutine block as a usual lambda if there is at least
 one such call.

 As a result, also remove diagnostic about non-applicable call as it
 become useless with current reanalysis

 #KT-37061 Fixed
 #KT-32097 Fixed
 #KT-32203 Fixed
 #KT-35306 Fixed
 #KT-36202 Fixed
 #KT-36220 Fixed
 #KT-32654 Fixed
2020-02-28 10:25:22 +03:00
Mikhail Zarechenskiy 5393074d61 [NI] Update type of complex subcall for last lambda expressions 2020-02-25 15:26:25 +03:00
Mikhail Zarechenskiy 1624327ba4 [NI] Fix substitution in builder-inference for empty common system 2020-02-21 14:24:57 +03:00
Dmitriy Novozhilov 102d5c7d5a [NI] Fix detecting expected type variable for postponed atoms
#KT-36819 Fixed
2020-02-20 16:56:33 +03:00
Mikhail Zarechenskiy 83824d0ba6 [NI] Don't stop on a candidate with unstable smartcast error
#KT-36847 Fixed
2020-02-20 12:34:34 +03:00
Mikhail Zarechenskiy cbbbf40b90 [NI] Fix isSuccessful property for member with LowPriority resolution
The problem was introduced in e40ba73950
2020-02-19 18:06:22 +03:00
Denis Zharkov c8269baa92 FIR: Fix NI handling flexible type bounds 2020-02-19 15:53:34 +03:00
Victor Petukhov 748a326104 NI: Discard definitely not-null types inside invariant positions during inference process
^KT-36816 Fixed
2020-02-19 15:32:12 +03:00
Denis Zharkov aac72871e7 Fix UI freezes caused by calls with a huge number overloads
While we have an overload resolution algorithm working for O(n^2),
call resolution for the single particular call may work more then just
a second.
Thus, we need to call ProgressManager.checkCanceled() with more granularity

^KT-35135 Fixed
2020-02-18 20:07:14 +03:00