Commit Graph

7 Commits

Author SHA1 Message Date
Denis.Zharkov f12a4e08cf K2: Do not force completion for 'when' branches with expected type
Otherwise, it leads to branches inference run fully independent,
while there are cases when it's necessary to flow type information from
one of the branch to another (see the new test).

NB. In K1, it worked differently: if branches were inferred altogether
only for Any/Any? expect types (otherwise they're analyzed independently)
See foo2/foo4 in the test.

To avoid breaking change we need to support foo1/foo3, but we're trying
not to have some special rule for Any, so we've got a new resolution mode
that provides expect type, but doesn't require full completion.

^KT-45989 Fixed
^KT-56563 Fixed
^KT-54709 Related

For change in specialCallWithMaterializeAndExpectedType.kt
At first, see at KT-36776

Long time ago, it's been decided that if/when resolution
should look similar to similar "select()" calls,
but it's a breaking change (see KT-36776), and we were ready for that back then.

But then, there were too many broken cases found, thus we reverted it at
100a6f70ca

But probably, it would be better to try to infer `String?`
instead of `Nothing?` (see next commits)

Note that change in specialCallWithMaterializeAndExpectedType.kt
will be addressed in later commits, too
2023-02-15 08:13:49 +00:00
Denis.Zharkov 33dcbaac16 K2: Change resolution rules of when/if expressions with expected type
When expected type is known, use it as expected type for branch bodies.
While it indeed becomes different from the usual select call resolution,
where expected type is applied only after completion starts,
it helps to support, e.g. callable references resolution just as powerful
as it was in K1.

Also, in some cases where diagnostics have been changed, they become
a bit more helpful since they are reported closer
to the problematic places

cannotCastToFunction.kt test has been removed because it relied
on the case erroneously supported by the hack removed from
the FirCallResolver in this commit.

^KT-45989 Fixed
^KT-55936 Fixed
^KT-56445 Fixed
^KT-54709 Related
^KT-55931 Related
2023-02-15 08:13:46 +00:00
Denis.Zharkov 9fa0f51a61 K2: Fix false-negative RETURN_TYPE_MISMATCH
^KT-53987 Fixed
^KT-55932 Fixed
2023-02-15 08:13:42 +00:00
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +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
simon.ogorodnik f573719cc1 [FIR] Fix missing receiver type if anonymous function without label 2020-04-08 14:56:17 +03:00
Dmitriy Novozhilov 2536fa0cd5 [FIR-TEST] Add new testdata generated after changes in previous commit 2019-12-12 16:11:46 +03:00