Mikhail Zarechenskiy
f702417655
[NI] Relax rules for call completion: require at least one constraint
...
It's enough to have at least one good constraint.
Note that the whole algorithm can be a bit more general:
we could check also Out<T>, In<T> and verify that T has good only
lower constraint or upper constraint, but there are questions for
types like Inv<Out<T>>, where T should have lower and upper constraints
#KT-31514 Fixed
2019-05-29 02:14:00 +03:00
Dmitriy Novozhilov
bfb13803d5
[NI] Fix reporting of overload resolution ambiguity
2019-04-19 14:46:22 +03:00
Mikhail Zarechenskiy
2fe900d915
[NI] Resolve lambda against input types from expected type
...
This is needed to report more precise diagnostics and fix IDE-tests
#KT-31059 Fixed
2019-04-19 09:08:31 +03:00
Mikhail Zarechenskiy
bcc8802014
[NI] Avoid constraints from expected type for effectively empty system
...
Expression will be checked against expected type later.
Theoretically, this is not very good, but it aligns with the old
inference, plus it helps avoiding multiple type mismatch diagnostics.
2019-04-17 12:55:12 +03:00
Mikhail Zarechenskiy
c458393e2f
[NI] Do not avoid trivial constraints if they aren't from upper bounds
...
Since we skipped trivial constraint with `Any?` from parameter type of
function `equals`, the compiler thought that there is no proper
constraints (upper bounds do not matter here) and marked resolved
call as a failed one, then diagnostic about missing equals was added
Also, tune `TrivialConstraintTypeInferenceOracle` for `Any?`-like
constraints
#KT-30724 Fixed
2019-04-02 12:21:14 +03:00
Dmitriy Novozhilov
9825984bc5
[NI] Update test data for diagnostic tests
2019-03-25 12:17:27 +03:00
Mikhail Zarechenskiy
9b3e17f0d7
[NI] Avoid building controversial systems by clipping extra constraints
...
#KT-23854 Fixed
2019-03-04 11:29:38 +03:00
victor.petukhov
46bd5ba107
Add alphabetical sorting diagnostics with same ranges
2019-02-14 12:31:42 +03:00
Dmitriy Novozhilov
42b333f6fd
Update some testdata according to new inference behaviour
2019-01-24 10:53:58 +03:00
Dmitry Petrov
b4dc3dc91b
Fix exhaustiveness check for when with subject variable
2018-06-20 14:06:34 +03:00
Dmitry Petrov
67247ee490
'val' in 'when' subject can't have modifiers (annotations are ok)
2018-06-20 14:06:34 +03:00
Dmitry Savvinov
148d03e365
Add some data flow analysis tests on when
2018-06-20 14:06:34 +03:00
Dmitry Petrov
ae929d0f08
Handle nested when with subject properly
...
Hack: callee expression for when with subject variable is the subject
variable declaration. This solves the problem that all sub-calls in the
expression are implicitly considered to have a single common lexical
scope (and 'when (val x = ...)' introduces a new lexical scope, which
contains 'x').
2018-06-20 14:06:34 +03:00
Dmitry Petrov
758548603e
Extra tests for when with val in subject
2018-06-20 14:06:34 +03:00
Dmitry Petrov
091b935c2d
Introduce separate callee expression for when with subject variable
...
'Subject.Error' is redundant.
'Subject.None' can be an object.
'Subject#dataFlowValue' can be a lateinit property.
TODO: fix
- parsing local extension properties in 'when' subject
- parsing destructuring declarations in 'when' subject
- non-completed calls in nested 'when' with subject variable
- non-completed calls for subject variable in 'in' pattern
2018-06-20 14:06:34 +03:00
Dmitry Petrov
5f0c9490bb
Add test for smart cast on a value bound to when subject variable
...
E.g.:
when (val y = x?.foo()) {
null -> ...
else -> ... // 'x' is also non-null here
}
2018-06-20 14:06:34 +03:00
Dmitry Petrov
0a0bc67e8a
Add test for UNUSED_VALUE on when subject variable
2018-06-20 14:06:34 +03:00
Dmitry Petrov
c20c1abb68
Add test for VAL_REASSIGNMENT on when subject variable
2018-06-20 14:06:34 +03:00
Dmitry Petrov
7bc89b8871
Report error on illegal variable declaration in when subject
2018-06-20 14:06:34 +03:00
Dmitry Petrov
098d3eb235
Make smart casts work with variable declared in when subject
2018-06-20 14:06:34 +03:00
Dmitry Petrov
1eeafc2d0e
Resolve variable declaration in 'when' subject
2018-06-20 14:06:34 +03:00
Dmitry Savvinov
33f9576dd1
[NI] Turn off KnownTypeParameterSubstitutor for NI
...
The main consequence of it is that TYPE_MISMATCH range for control
structures became wider.
Also, for extra safety, don't change behaviour of OI.
2017-12-07 14:05:42 +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
fitermay
e30b9758f4
Introduce action to add missing when branches on sealed class
...
Made via diagnostics NON_EXHAUSTIVE_WHEN_FOR_SEALED_CLASS
with INFO severity and quick-fix
So #KT-17580 Fixed
2017-05-16 16:43:27 +03:00
Dmitry Neverov
cd24adac32
Detect redundant 'is' check
...
#KT-14187 Fixed
2017-05-15 11:24:35 +03:00
Mikhail Glukhikh
14886827a2
Introduce warning REDUNDANT_ELSE_IN_WHEN #KT-17497 Fixed
2017-05-04 14:17:41 +03:00
Mikhail Glukhikh
7a53b2f4c8
Introduce UNUSED_ANONYMOUS_PARAMETER for anonymous functions
...
It is not reported for 1.0 language version because
renaming to _ is not possible. It has weak warning severity
So #KT-8813 Fixed
So #KT-16875 Fixed
2017-04-04 14:23:30 +03:00
mglukhikh
f64345634b
WHEN_ENUM_CAN_BE_NULL_IN_JAVA is no more reported after smart cast to not-null #KT-15201 Fixed
2017-01-24 13:51:15 +03:00
Mikhail Zarechenskiy
76b0b785c5
Prohibit to use enum entry as a type
...
#KT-14179 Fixed
2017-01-09 18:30:32 +03:00
Denis Zharkov
4c69416f2b
Report warning on unused entities that can be renamed to _
...
Currently it's all about lambda parameters/destructuring entries
#KT-14347 In Progress
2016-10-24 10:19:25 +03:00
Valentin Kipyatkov
ec51076355
DescriptorRenderer to render annotations for all types + separate option to render annotation arguments + use it in IdeDescriptorRenderers
2016-10-11 23:38:54 +03:00
Michael Bogdanov
3b419e8ba3
Fix for KT-11964: No TABLESWITCH in when on enum bytecode if enum constant is imported
...
#KT-11964 Fixed
2016-06-29 09:32:45 +03:00
Stanislav Erokhin
7332032bb6
Support sealed class inheritors in the same file
...
#KT-11573 Fixed
2016-05-19 16:22:40 +03:00
Denis Zharkov
d0acb3674a
Fix rendered testData
...
New members in enum member scope
2016-05-16 15:38:13 +03:00
Mikhail Glukhikh
771fb0ace2
Compiler warning on identical enum constant / is type entries #KT-4829 Fixed
2016-04-20 12:21:31 +03:00
Alexander Udalov
1b8f934b54
Delete deprecated enum 'values' property
2016-02-19 22:28:44 +03:00
Dmitry Petrov
c5fd496cc9
Fix KT-10805 for 'when'.
2016-01-27 17:07:20 +03:00
Dmitry Petrov
9db3440e72
Fix type inference issues for 'if' and 'when'.
...
Use 'expectedType' (when present) as an explicit type argument for a special construct call.
Unfortunately, this approach can't be used for elvis due to other elvis-related inference hacks.
Fixes KT-10807, KT-10811.
This also affects KT-6189: now we can infer proper type for 'if'.
If type inference for special call failed, and we found no type errors in sub-expressions,
report TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT error.
This (and the hack above) fixes KT-10809: code no longer compiles.
2016-01-27 17:07:20 +03:00
Dmitry Petrov
f371e67ce8
PatternMatchingTypingVisitor:
...
rewrite type inference for 'when' using special constructs.
This fixes several type inference issues for 'when':
KT-9929, KT-9972, KT-10439, KT-10463
along with some other diagnostics-related issues.
2016-01-22 10:41:55 +03:00
Mikhail Glukhikh
9360bd49a6
Data flow info: correct disjunction of a type with Nothing: Type U Nothing = Type #KT-9578 Fixed
2016-01-19 16:01:10 +03:00
Mikhail Glukhikh
011a9f23b9
Implicit exhaustive when check for definite variable initialization (KT-8700)
2015-12-26 10:46:35 +03:00
Mikhail Glukhikh
b93894953d
Exhaustive whens without else and 'Nothing' as the result are considered 'implicit exhaustive'
2015-12-26 10:46:11 +03:00
Mikhail Glukhikh
b805ce06c2
CFG exhaustive when else instruction for KT-8700
2015-12-26 10:46:01 +03:00
Andrey Breslav
75ab0dd509
'sealed' reserved in front of when
2015-12-18 21:20:54 +03:00
Mikhail Glukhikh
c8b50eec1e
Enum.values: deprecation (warning) --> deprecation (error)
2015-12-11 11:11:42 +03:00
Dmitry Petrov
76931affc6
KT-10139:
...
Non-exhaustive 'when' without 'else' used in expression is an error
regardless of expected type: it can't be an expression, even of type Unit.
2015-12-01 10:36:40 +03:00
Mikhail Glukhikh
89e56093a2
Limit "always null" scope: only for !!, is and dot; senseless comparison rolled back; "smart constant" information for nulls #KT-10029 Fixed
2015-11-25 18:26:08 +03:00
Dmitry Petrov
da90c21284
Warn about comma-separated conditions in when without argument.
...
See KT-5143.
2015-11-25 15:39:23 +03:00