Commit Graph

212 Commits

Author SHA1 Message Date
Ilmir Usmanov 8cc5f2abfb Forbid val field initialization inside EXACLTY_ONCE lambda
unless the lambda is inline. This way, final field will remain final.
2020-06-04 21:26:48 +02:00
Denis Zharkov b691b13d8e FIR: Add separate local scopes for blocks 2020-05-15 16:04:44 +03:00
Victor Petukhov 260683c20e NI: Improve postponed arguments analysis
Introduce seven stages:
1) Analyze postponed arguments with fixed parameter types
2) Collect parameter types from constraints and lambda parameters' declaration
3) Fix not postponed variables for parameter types of all postponed arguments
4) Create atoms with revised expected types if needed
5) Analyze the first ready postponed argument and rerun stages if it has been analyzed
6) Force fixation remaining type variables: fix if possible or report not enough information
7) Force analysis remaining not analyzed postponed arguments and rerun stages if there are

^KT-37952 Fixed
^KT-32156 Fixed
^KT-37249 Fixed
^KT-37341 Fixed
2020-05-07 11:42:00 +03:00
Mikhail Glukhikh 036b6c63f6 [FIR] During resolve, set correctly property reference type in delegate 2020-04-03 13:18:47 +03:00
Mikhail Glukhikh b27152f903 Replace some FIR syntax errors with more proper diagnostics 2020-03-27 16:46:59 +03:00
Dmitriy Novozhilov 8023d04c61 [FIR] Add separate local scope for init blocks 2020-03-05 16:48:47 +03:00
Mikhail Glukhikh 8884cbe415 Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed 2020-03-05 09:39:40 +03:00
Ilya Chernikov 6356807997 Reapply "Only create descriptors for candidates with lambda args"
#KT-36247 fixed
A lot of testdata changed because significanly less (error) descriptors
are created for unresolved types, so diagnostics became different.
2020-02-14 11:41:30 +01:00
Pavel Kirpichenkov 78c9bbcc0d [NI] Soften restictions on using Nothing as proper constraint for full call completion
Consider lower `Nothing` constraint non-proper only if there is a dependant not analyzed postponed atom.
Early completion to `Nothing` provides data flow info for smart casts.

KT-35668 Fixed
2020-01-23 19:12:01 +03:00
Mikhail Glukhikh 5c6341b4e4 [FIR] Handle fully qualified expressions separately in tower resolver 2020-01-13 13:26:13 +03:00
Pavel Kirpichenkov 2d21b82501 [NI] Remove hack for special functions
Treating special functions for `if`, `when`, `try`, `?:` as not accepting `Nothing` result type is incorrect.
Making so leads to cases with uninferred `Nothing` result type for inner calls and lost data flow info.
2019-12-27 18:40:42 +03:00
Dmitriy Novozhilov e83941a98e [NI] Don't resolve delegates twice
#KT-31219 Fixed
#KT-31679 Fixed
#KT-32249 Fixed
2019-12-26 10:54:06 +03:00
Dmitriy Novozhilov 0c01499d98 [NI] Improve completing calls with multiple postponed arguments
#KT-27999 Fixed
#KT-30244 Fixed
#KT-31102 Fixed
2019-12-26 10:53:03 +03:00
Pavel Kirpichenkov a9391c8dfb [NI] Remove Nothing result type restriction in most cases
Make Nothing as result type not suitable only for if, when, try and ?: special functions.
2019-12-25 14:59:05 +03:00
Mikhail Zarechenskiy ae1630f376 [NI] Don't discriminate Nothing-type from resulting ones
^KT-32106 Fixed
2019-12-25 14:59:04 +03:00
Dmitriy Novozhilov 2536fa0cd5 [FIR-TEST] Add new testdata generated after changes in previous commit 2019-12-12 16:11:46 +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
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
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
victor.petukhov d4515031de Report warning about implicitly inferred nothing only for return position
^KT-31535 Fixed
2019-05-22 15:45:59 +03:00
Dmitriy Novozhilov e70bdb51c5 [NI] Automatically squash equal diagnostics in OI and NI in testdata 2019-04-19 10:53:19 +03:00
Mikhail Zarechenskiy ca894a6a71 [NI] Don't complete nested call if there's no constraints at all 2019-03-25 12:17:28 +03:00
Dmitriy Novozhilov 9825984bc5 [NI] Update test data for diagnostic tests 2019-03-25 12:17:27 +03:00
victor.petukhov 70c35f4186 Introduce warning about implicitly inferred Nothing as a type parameter
^KT-20849 Fixed
2019-03-15 19:28:38 +03:00
victor.petukhov 46bd5ba107 Add alphabetical sorting diagnostics with same ranges 2019-02-14 12:31:42 +03:00
Mikhail Glukhikh ad44118605 Delay UNUSED_PARAMETER on main parameter until 1.4 (part of KT-26999) 2018-10-31 19:00:29 +03:00
Mikhail Glukhikh f3555daa60 Report UNUSED_PARAMETER on main parameter in 1.3+ #KT-26999 Fixed 2018-10-25 19:10:39 +03:00
Dmitry Petrov df6d4f358a KT-22274 report warning on labels that can't be referenced
Labels are meaningful only if they can be referenced by 'break',
'continue', or 'return' expressions.
2018-07-25 12:08:20 +03:00
Dmitry Savvinov 5cb949ad7f Fix language features in tests for gradual migration to 1.3 (part 2)
In 1.3, due to changes in language, testdata for some tests can be
different from 1.2

We want to simlultaneously test both versions, so instead of fixing
language version in such tests, we split them into two: one with fixed
1.2, another with fixed 1.3
2018-07-05 10:42:49 +03:00
Mikhail Zarechenskiy 9891f562cc [NI] Make subtyping algorithm more robust to error types
During subtyping/incorporation we transform types (e.g. changing nullability,
 form of the type) and, basically, we're doing this to some FIXPOINT.
 It's important that we use `KotlinType.hashCode()` to compare types, but
 for error types hashCode is a hashCode of its supertype and, for example,
 `makeNullableAsSpecified` method recreate type every time. So, we continue
 to generate new constraints and we'll never stop incorporation algorithm
2018-06-07 15:45:53 +03:00
Mikhail Zarechenskiy 612baacc25 Make useless elvis diagnostic more consistent for new and old inference
Also, remove diagnostics that can be covered by usual USELESS_ELVIS diagnostic
2018-04-12 14:38:55 +03:00
Mikhail Zarechenskiy 3afd4a2f4a [NI] Record all diagnostics from subcalls resolution results 2018-02-14 14:58:04 +03:00
Dmitry Savvinov ea72c76a37 [NI] Testdata changes after fixes in error types 2017-12-07 12:49:56 +03:00
Mikhail Zarechenskiy 328c67b9e8 Add separate diagnostic renderer results for tests with NI 2017-11-29 02:54:30 +03:00
Mikhail Zarechenskiy 8757298994 Add diagnostics to test data from NI 2017-11-29 02:54:26 +03:00
Mikhail Zarechenskiy a71238bf94 Place !WITH_NEW_INFERENCE directive to diagnostics test data 2017-11-29 02:53:49 +03:00
Denis Zharkov 1f9d56439a Fix KNPE caused by optimizations in control-flow analysis
The problem is that when performing full analysis we do it in
a backward order while result for trivial vals is filled
in a forward one.

It turns out that reversedInstuctions might return a superset of
forward traversed instructions, e.g. in case of dead code in lambda.

At the same time result for trivial vals is constant
for any instruction, thus we can just return its constant value
and use it in the full analysis

 #KT-20895 Fixed
2017-11-14 16:38:28 +03:00
Denis Zharkov a51078fda6 Turn off optimizations in case of do-while presence 2017-10-02 10:04:16 +03:00
Denis Zharkov c31b5beb9e Remove redundant check for a variable being initialized after write
It's anyway is obvious for write instruction, while effectively
after optimizations we treat val with syntactic initializer
uninitialized until their immediate initiazer
2017-10-02 10:04:16 +03:00
Denis Zharkov 527daced46 Optimize CFG for cases of simple variables
Parameters/vals with an immediate initializer (which we assume is a
rather common situation) do not require any kind of complicated CFA

- Unused vals can be simply determined by linear traversal of
  the pseudocode
- Definite assignment is a bit more complicated: a read-instruction of val
  can be considered as a safe if it's located *after* the first write in
  the pseudocode. It works almost always beside the case with do/while
  (see the test changed). This case will be fixed in the further commits

The test for kt897.kt will also be fixed further, all other changes
might be considered as minor as they mostly change diagnostics for
already red code
2017-10-02 10:04:16 +03:00
Dmitry Petrov 2b27e64fc8 Improve diagnostics for "not yet supported in inline"
- Tell user what exactly is not supported (e.g., local inline function)
- Reduce diagnostics range to a keyword or an identifier
  where appropriate

 #KT-16223 Fixed Target versions 1.1.50
2017-09-06 09:46:33 +03:00
Mikhail Zarechenskiy 2d3ce89afc Use only completed arguments of special call 2017-07-13 12:26:03 +03:00
Dmitry Neverov cd24adac32 Detect redundant 'is' check
#KT-14187 Fixed
2017-05-15 11:24:35 +03:00
Mikhail Zarechenskiy 7530a9426f Warn about val reassignment via backing field
#KT-16681 In Progress
2017-05-05 21:30:37 +03:00
Mikhail Glukhikh 14886827a2 Introduce warning REDUNDANT_ELSE_IN_WHEN #KT-17497 Fixed 2017-05-04 14:17:41 +03:00
Mikhail Glukhikh b5d0de7c3f Add test for KT-17479 looks like #KT-17479 Fixed
(after CAPTURED_MEMBER_VAL_INITIALIZATION introduction)
2017-05-02 19:59:43 +03:00
Mikhail Glukhikh 28283bad3e Introduce special CAPTURED_VAL_INITIALIZATION for members 2017-05-02 19:59:37 +03:00
Mikhail Glukhikh 56e633e345 CFA: detect captured writes more precisely
So #KT-14381 Fixed
So #KT-13597 Fixed
Also refactors captured writes detection inside DFA
2017-05-02 19:59:23 +03:00
Mikhail Glukhikh 8fa739ed0f Test for KT-14381 and KT-13597 2017-05-02 19:02:01 +03:00