Commit Graph

216 Commits

Author SHA1 Message Date
Stanislav Erokhin 3cf240340c [NI] Extract logic about fixation order to separated component 2017-08-23 15:53:39 +03:00
Stanislav Erokhin ff1e230828 [NI] Use right scope for callable reference resolution
Previously was used scope for top-level call. It isn't correct because
if we have callable reference inside lambda -> scope is different.
2017-08-23 15:53:38 +03:00
Stanislav Erokhin da003d48ff Support isSuccessful in SuccessfulResultCollector
Since now SuccessfulResultCollector do not run computation of
resultingApplicability for error candidate before
getFinalCandidates(). It is very useful because we can do not run
all checks for error candidates if we have not-error candidate.
2017-08-23 15:53:37 +03:00
Stanislav Erokhin 6b8293ae5b Refactoring. Remove ResolutionCandidateStatus.
Use diagnostics directly.
Also TowerCandidate since now know only about applicability
and not about diagnostics itself.
2017-08-23 15:53:36 +03:00
Stanislav Erokhin cdaa98fb63 [NI] Fixes after review 2017-08-23 15:53:33 +03:00
Stanislav Erokhin 2b01b91315 [NI] Refactoring: KotlinCallContext to stateless component (2) 2017-08-23 15:53:32 +03:00
Stanislav Erokhin e88c1b4f0a [NI] Refactoring: KotlinCallContext to stateless component (1) 2017-08-23 15:53:31 +03:00
Stanislav Erokhin 9bbfac11b4 [NI] Add common supertype for PSI lambda arguments
Also move initial dataFlowInfo to lambda arguments.
As result, we can not store outer call for postpone call arguments
2017-08-23 15:53:30 +03:00
Dmitry Petrov 674d30cd76 Report deprecation on typealias companion object for deprecated alias 2017-08-10 15:45:44 +03:00
Mikhail Zarechenskiy 053b02e0df [NI] Fold { Lower | Upper } & Equality constraints if it's possible 2017-08-09 14:00:53 +03:00
Valentin Kipyatkov 9361cd895c Support for import aliases in code completion
#KT-8848 Fixed
2017-08-08 22:06:04 +03:00
Mikhail Zarechenskiy 48246e5f34 [NI] Add resolution part to check for abstract super call 2017-08-08 15:44:31 +03:00
Mikhail Zarechenskiy 9e018fa094 [NI] Try to analyze each lambda at least once 2017-08-07 18:01:20 +03:00
Mikhail Zarechenskiy 07a4496054 [NI] Resolve lambda even if there is contradiction in CS
To avoid exceptions about non-recorded lambda
2017-08-07 18:01:19 +03:00
Stanislav Erokhin 6680f01cfe [NI] Fix assertion error at FlexibleTypeImpl
Use KotlinTypeFactory for FlexibleType creation
2017-08-07 18:01:14 +03:00
Mikhail Zarechenskiy e7cd615450 [NI] Introduce type depth in CS calculator to avoid SOE 2017-08-07 18:01:13 +03:00
Mikhail Zarechenskiy ac507e721c [NI] Do not add non-dynamic candidates when there is dynamic extension 2017-08-07 18:01:11 +03:00
Mikhail Zarechenskiy 0d464f06d1 [NI] Consider CS as nullable if one of the types isn't subtype of Any
Note that this isn't fully correct, consider the following situation:

S : T, T : Any?
=> CS(S, T) = T, but for now it will be T?, which is reliable but not so specific as just T
2017-08-07 18:01:09 +03:00
Mikhail Zarechenskiy 39349abd39 [NI] Preserve name of parameters for functional types 2017-08-07 18:01:07 +03:00
Dmitry Petrov c0d6eff97c [NI] Select variable with proper non-trivial constraint first 2017-08-07 18:01:05 +03:00
Dmitry Petrov 0bf81aeec0 [NI] Extract InferenceStepResolver into a separate component 2017-08-07 18:01:04 +03:00
Dmitry Petrov 258a5aea28 [NI] Minor cleanup in FixationOrderCalculator 2017-08-07 18:01:03 +03:00
Stanislav Erokhin ab2f99542a [NI] Redo how we take care of postpone arguments
The main change here is the following: before callable reference
resolution starts directly after choosing candidate. Since now we
start resolution before call completion.
2017-08-07 18:01:02 +03:00
Stanislav Erokhin b344865c15 [NI] Minor. Fixes after review 2017-08-07 18:01:01 +03:00
Stanislav Erokhin 93d80c252f [NI] Refactoring. Move properties from KotlinCall to external component 2017-08-07 18:01:00 +03:00
Stanislav Erokhin ef93088a42 [NI] Move most of KotlinCallDiagnostic to one file
Now there is 3 kind of KotlinCallDiagnostic:
  - ResolutionDiagnostic
  - ConstraintSystemCallDiagnostic
  - other common diagnostic

Also SpecialResolutionParts were merged into other ResolutionParts
2017-08-07 18:00:59 +03:00
Stanislav Erokhin 9378bff65c [NI] Move irrelevant code from KotlinCallCompleter
Extract code about smart cast diagnostic to new component
AdditionalDiagnosticReporter
2017-08-07 18:00:58 +03:00
Stanislav Erokhin 3450340d7f [NI] Refactoring. Introduced PostponableCallArgument
Also here argument resolution was divided to two parts:
for SimpleCallArguments and for PostponableCallArguments.
Call Resolution for SimpleCallArguments also used for CheckReceivers
and lambda result arguments checks
2017-08-07 18:00:57 +03:00
Stanislav Erokhin 1bc68e073d [NI] Minor. Clarified type for arguments from lambda 2017-08-07 18:00:56 +03:00
Stanislav Erokhin 4848f8e3da [NI] Use correct type in TypeApproximator for Invariant projection 2017-08-07 18:00:56 +03:00
Stanislav Erokhin 455c43afa8 [NI] Some improvements in callable reference resolution 2017-08-07 18:00:53 +03:00
Stanislav Erokhin f1144c9f01 [NI] Use resolved lhsType as unbound receiver. 2017-08-07 18:00:53 +03:00
Stanislav Erokhin c752e1580e [NI] Check receivers for callable reference resolution. 2017-08-07 18:00:52 +03:00
Mikhail Zarechenskiy 7802492b08 [NI] Fix resulting type when there are no proper constraints 2017-08-07 18:00:50 +03:00
Mikhail Zarechenskiy 6be726854f [NI] Preserve type abbreviation during type substitution 2017-08-07 18:00:49 +03:00
Dmitry Petrov 4963580f90 [NI] Take into account return without expression in lambdas 2017-08-07 18:00:47 +03:00
Mikhail Zarechenskiy 17cdbcca03 [NI] Approximate substituted type arguments for non-members 2017-08-07 18:00:46 +03:00
Stanislav Erokhin 915ac32bfb [NI] Improve type inference for T vs Captured(in Smt)
If we has Inv<T> <: Inv<Captured(in Foo)> then we should get:
- T <: Captured(in Foo)
- Captured(in Foo) <: T

Before this commit we got: T <: Foo instead first constraint.
2017-08-07 18:00:45 +03:00
Stanislav Erokhin 91241a34d1 [NI] Run checks for captured types only once in NewTypeSubstitutor
Sometimes we can get Enum<Captured(*)> type here, so, supertype for
Captured(*) is Enum<Capture(*)> and we go into SO.
2017-08-07 18:00:44 +03:00
Mikhail Zarechenskiy ffc130f5fb [NI] Always approximate captured types for property descriptors 2017-08-07 18:00:41 +03:00
Stanislav Erokhin 5f2cc75718 [NI] Support INAPPLICABLE_WRONG_RECEIVER candidate applicability
It is important for provideDelegate resolution, because if scope has
provideDelegate with wrong receiver we shouldn't resolve to it and
report any errors.
2017-08-07 18:00:40 +03:00
Dmitry Petrov e5c87fdad7 [NI] Filter out duplicates types in commonSuperTypeForNotNullTypes 2017-08-07 18:00:36 +03:00
Dmitry Petrov 397e04f382 [NI] Do not use return type from 'onlyResolvedCall' 2017-08-07 18:00:34 +03:00
Mikhail Zarechenskiy def0816095 [NI] Write info about hidden descriptor to candidate 2017-08-07 18:00:30 +03:00
Mikhail Zarechenskiy 38d9123a57 [NI] Use weaker upper constraint for case {T & Any} <: S 2017-08-07 18:00:29 +03:00
Dmitry Petrov fbad16567b [NI] Fix number type adjustment for greatest lower bound calculation
Compute common supertype (regardless of whether the given set of
lower bounds contains number types, intersection types, or whatever).

If the result type S is a possibly nullable intersection X1 & ... & Xn,
N = {Xi | Xi is a primitive number type},
R = {Xi | Xi is not a primitive number type},
M = default primitive number type for {Nj},
then adjusted type T* = M & R1 & ... Rm with the same nullability as S.

NB: IntegerValueType(_) = Int & Byte & Short & Long
2017-08-07 18:00:26 +03:00
Dmitry Petrov 1ae4278cfd Minor: fix formatting 2017-08-07 18:00:25 +03:00
Mikhail Zarechenskiy bc2a8555a3 [NI] Resolve collection literals arguments as postponed ones 2017-08-07 18:00:24 +03:00
Stanislav Erokhin c0c94910e2 [NI] Fix StackOverflow in TypeApproximator
For cases like Enum<Captured(*)> where Captured(*) has supertype
Enum<Captured(*)> we get SO in TypeApproximator.
To prevent this argument depth was introduced.
2017-08-07 18:00:23 +03:00
Dmitry Petrov 9fa3bce73a [NI] Fix special case of captured type handling in subtyping
Given the subtyping constraint
  X <: CapturedType(in Y)
we should check only
  X <: Y
if X contains type variables.
2017-08-07 18:00:22 +03:00