Dmitriy Novozhilov
f26059a7d3
[FE] Add clear warning about future changes about nullability of safe call with non nullable receiver
...
^KT-46860
2021-10-27 16:28:37 +03:00
Denis.Zharkov
a0a57581ec
FIR: Do not add alias for variables with explicit type
2021-10-20 22:05:24 +03:00
Tianyu Geng
765cad8448
FIR checker: substitute type parameters in dispatch receiver type
...
Consider the following code:
```
fun test(a: List<String>) {
a.first()
}
```
The dispatch receiver type of `first` in this case is `List<T>` before
this change. After this change, it's `List<String>`.
In addition, this change also replace the dispatch receiver type with
the more specific type if available. For example, consider the following
```
class MyList: ArrayList<String>()
fun test(a: MyList) {
a.get(0)
}
```
The dispatch receiver type of `get` is `MyList`, instead of
`ArrayList<String>`. That is, a fake override is created in this case.
2021-09-17 01:59:06 +03:00
Ivan Kochurkin
84c5f58cab
[FIR] Implement UNRESOLVED_REFERENCE_WRONG_RECEIVER
2021-08-25 21:53:23 +00:00
Dmitriy Novozhilov
1d491fdce6
[FIR] Don't create union call node for lambda from one when branch and call from condition of another
2021-08-06 22:57:18 +03:00
Tianyu Geng
c7272f6986
FIR checker: SENSELESS_(COMPARISON|NULL_IN_WHEN)
...
Currently DFA does not set "definitely equal to null" for access to variables that got assigned `null`. For example, FIR should mark the following line as SENSELESS_COMPARISON due to `s = null` above.
https://github.com/JetBrains/kotlin/blob/d1531f9cdd5852352c0133198706125dc63b6007/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.fir.kt#L6
The problem is at https://github.com/JetBrains/kotlin/blob/7e9f27436a77de1c76e3705da7aa1fbe8938336b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt#L1104
For null assignment, ideally the type should be `Nothing?`. This is
addressed in a followup commit instead.
2021-08-06 22:57:16 +03:00
Tianyu Geng
4726dcce40
FIR DFA: smartcast variable to Nothing? on null assignment
...
In order to make resolution still work for members not available from
`Nothing`, we track the type without `Nothing?` and use that for
resolution instead.
2021-08-06 22:57:15 +03:00
Mark Punzalan
504449f03e
FIR: Report UNSAFE_CALL instead of SMARTCAST_IMPOSSIBLE when smartcast
...
to null.
Currently the error message shows the expression is impossible to
smartcast to the nullable type, which is nonsensical since it's already
that type.
2021-07-30 21:49:50 +03:00
Andrey Zinovyev
7e9f27436a
[FIR] Fix cfg for safe call inside elvis
2021-07-19 13:40:31 +03:00
Andrey Zinovyev
a6984c5198
[FIR] Add NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY diagnostic
2021-07-19 13:40:28 +03:00
Dmitriy Novozhilov
4225813d79
[FIR] Update CFG dumps according to changed order of visiting class children
2021-06-29 21:03:29 +03:00
Tianyu Geng
ce767046eb
FIR checkers: report SMARTCAST_IMPOSSIBLE
2021-06-10 16:01:13 +03:00
Dmitriy Novozhilov
796f8e6bce
Revert "FIR checkers: report SMARTCAST_IMPOSSIBLE"
...
This reverts commit 84334b08
2021-06-03 09:48:50 +03:00
Tianyu Geng
84334b087c
FIR checkers: report SMARTCAST_IMPOSSIBLE
2021-06-02 13:19:12 +03:00
Mark Punzalan
9cf5ac1fbd
FIR: Render "?" on nullable function types.
2021-04-26 15:11:37 +03:00
Jinseong Jeon
24d792fb49
FIR checker: warn useless elvis
2021-04-22 13:10:54 +03:00
Tianyu Geng
6a03f31e50
FIR: add UnsafeCall resolution diagnostics
...
Previously unsafe call is reported as part of InapplicableWrongReceiver.
This makes it difficult for the downstream checkers to report different
diagnostics.
2021-04-19 15:11:13 +03:00
Mikhail Glukhikh
43a2ad0467
FIR: don't flatten for loop blocks in raw FIR builder
2021-04-19 15:11:12 +03:00
Ilya Kirillov
0cf00d0f72
FIR: fix FirDefaultPropertyAccessor phase to BODY_RESOLVE
2021-04-15 15:23:56 +03:00
Jinseong Jeon
5a0b75bd89
FIR checker: warn unnecessary safe calls
2021-04-09 12:32:45 +03:00
Dmitriy Novozhilov
5ebd24eac5
[FIR] Save inline status of lambda after resolution
2021-04-06 12:30:34 +03:00
Mikhail Glukhikh
111e67dc8d
Use DECLARATION_NAME strategy for FirErrors.PRIMARY_CONSTRUCTOR_REQUIRED
2021-03-11 13:25:52 +03:00
Tianyu Geng
6e8bad6ef6
FIR: Implement data class constructor checker
2021-03-11 13:25:51 +03:00
Jinseong Jeon
6427117a35
FIR CFG: correct edge label from a node that returns Nothing
...
If it's not within a try/catch/finally, that should be an uncaught
exception path.
^KT-45327 Fixed
2021-03-09 14:44:42 +03:00
Dmitriy Novozhilov
a6d1d47918
[FIR] Fix clearing info about DF variable after reassignment
2021-03-04 17:09:17 +03:00
Dmitriy Novozhilov
1c0d862e40
[FIR] Don't smartcast variables to invisible types
...
#KT-44802 Fixed
2021-02-20 10:23:33 +03:00
Mikhail Glukhikh
34c90aab3b
FIR: introduce & use REFERENCE_BY_QUALIFIER positioning strategy
2021-02-19 18:24:46 +03:00
Dmitriy Novozhilov
9b4949a3c5
[FIR] Fix taking symbol of expression with smartcast inside DFA
2021-02-18 10:10:38 +03:00
Dmitriy Novozhilov
2d5b685535
[FIR] Fix processing constructors of sealed classes
...
- Allow declaring protected constructors in sealed classes
- Make default visibility of sealed class constructor `protected`
KT-44861
KT-44865
2021-02-12 13:36:41 +03:00
Dmitriy Novozhilov
9724d81a49
[FIR] Support boolean elvis bound smartcasts
...
#KT-44511 Fixed
2021-02-09 15:20:36 +03:00
Mikhail Glukhikh
7d4eaefd36
FIR: report UNSAFE_CALL on dot when possible
2021-01-29 16:55:26 +03:00
Jinseong Jeon
e72ddbcbfe
FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
...
To do so, inside the root cause of inapplicable candidate errors,
we will record expected/actual type of receiver, if any.
That will help identifying inapplicable calls on nullable receiver.
2021-01-29 16:54:23 +03:00
Mikhail Glukhikh
4fd4f504d0
FIR: make componentX functions operator
2021-01-22 18:11:57 +03:00
Mikhail Glukhikh
40bec30393
FIR: implement LT positioning in diagnostic tests, fix LT strategies
2021-01-21 16:06:09 +03:00
Jinseong Jeon
f1d8a6e5d1
FIR checker: introduce DECLARATION_SIGNATURE_OR_DEFAULT positioning strategy
...
and fix CONFLICTING_OVERLOADS to use it
2021-01-21 16:06:09 +03:00
Dmitriy Novozhilov
e1802fde29
[TD] Update test data after previous commit
2020-12-16 19:52:30 +03:00
Dmitriy Novozhilov
e6b5cb5216
[TD] Update diagnostics test data due to new test runners
...
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00
Denis Zharkov
65119adb6a
FIR: Adjust test data. FakeOverride -> SubssitutionOverride
2020-11-06 11:32:39 +03:00
Mikhail Glukhikh
e9b51b42f9
[FIR] Add test for both KT-10240 and KT-19446
2020-10-26 14:09:36 +03:00
Dmitriy Novozhilov
f794ced888
[FIR] Fix incorrect cluster creating in CFG dumps
2020-10-12 11:55:05 +03:00
Dmitriy Novozhilov
68f3d84e22
[FIR] Use CandidateApplicability from FE 1.0
2020-09-09 12:38:34 +03:00
Jinseong Jeon
ca541337d1
FIR: skip return insertion for lambda w/ Unit return type
2020-08-21 19:16:43 +03:00
Oleg Ivanov
4367d6631f
[FIR] Add CallsInPlace contract analyzer
2020-08-11 16:17:01 +03:00
Oleg Ivanov
cc9c5b9e3c
[FIR] Add CFG nodes, add multiple subGraphs for CFGOwner
2020-08-11 16:17:01 +03:00
Nick
4669e019d1
[FIR] Add diagnostic CONFLICTING_OVERLOADS & REDECLARATION
2020-08-10 10:09:37 +03:00
Nick
7145caca40
[FIR] Refactor effective visibility calculation
...
Before this commit, we had effective visibility as a part of FIR status,
so it was integrated into the full pipeline. In this commit,
we introduced "effective visibility as a service" which is now used
only by exposed visibility checker. This allows us to make the thing
universal for all FIR nodes, including nodes for Java / deserialized.
2020-07-31 19:27:58 +03:00
Dmitriy Novozhilov
f283f2db43
[FIR] Improve diagnostic reporting & don't use error symbol for candidate if possible
...
Also introduce few new diagnostics:
- NONE_APPLICABLE more many inapplicable candidates
- HIDDEN for visible candidates
2020-07-28 20:46:56 +03:00
Ivan Kylchik
3c01a39846
[FIR] Update test data after introducing new fir nodes
2020-07-21 13:54:17 +03:00
Ivan Kylchik
85e822e283
[FIR] Support smartcast after reference equality check
...
#KT-39000 Fixed
2020-07-16 12:43:55 +03:00
Dmitriy Novozhilov
1db2ba51d2
[FIR] Don't pass flow from inplace lambdas throw when and elvis expressions
...
#KT-39080 Fixed
2020-07-03 17:09:29 +03:00