Commit Graph

7 Commits

Author SHA1 Message Date
Simon Ogorodnik 3e6b42083b FIR: Fix leakage of type variables in builder inference for lambdas returning Unit
When BI/incomplete call is present in return argument, it will be
added to the main call-tree, leading to requirement violation in
`ConstraintSystemCompleter.getOrderedAllTypeVariables`
as after `FirBuilderInferenceSession.inferPostponedVariables` it will
be completed, and its type variables couldn't be found anymore

In K1, we actually do the same, but we are able to find type variables
of such calls due to architecture difference:
In K2, `getOrderedAllTypeVariables` uses FIR as the main source to
lookup
In K1, `getOrderedAllTypeVariables` uses resolution atom tree, where
candidate/CS of the call is still available after
`inferPostponedVariables`

In fact, all incomplete calls were analyzed in FULL mode according to
the contract of `FirBuilderInferenceSession.addPartiallyResolvedCall`.
Thus, it means we normally shouldn't add them to the main call-tree, but
accidentally do it as incomplete calls contain non-completed candidate

This particular commit addresses the problem partially, only
in cases when the expected return type for the lambda is Unit and when
the incomplete call is located in the last expression of the lambda

In such cases, we can skip the call from the last expression completely,
since all potential calls there were analyzed in FULL mode,
and couldn't introduce any useful info to the CS of the main call-tree

^KT-54294
2023-05-17 10:50:36 +00:00
Simon Ogorodnik 4d1ea06c17 FIR. Document current builder inference algorithm 2023-05-10 10:40:04 +00:00
Jinseong Jeon 4700ad3e9e Docs: fix links to sources in FIR plugins 2022-06-08 11:28:56 +02:00
Dmitriy Novozhilov 7048cac770 [FIR] Move FirPredicateBasedProvider to :compiler:fir:tree module 2022-06-07 14:12:17 +00:00
Dmitriy Novozhilov 086d874fe2 Docs: Fix links to sources in FIR Plugins documentation 2022-01-31 16:28:03 +03:00
Dmitriy Novozhilov ee180a37a6 Docs: add basic FIR plugin API documentation 2022-01-24 11:11:07 +03:00
Ilya Kirillov d1335d3f44 Docs: add basic FIR compiler documentation
Originally written by Dmitriy Novozhilov
2022-01-21 15:56:47 +01:00