mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 15:53:46 +00:00
Before this change the check was quite complicated
because of cases like:
for (i in 1..9)
foo(i)<caret>
It's not located in a block, but in the same time it's a stament.
So we had a tricky heuristics that if is parent is not a block, then
we should check if element isn't used as expression.
Of course this heuristics is wrong, e.g. for import/package nodes.
The solution is to reuse similar logic from BasicExpressionTypingVisitor.
it has been checked once that statement container is one of:
- KtBlockExpression
- KtContainerNodeForControlStructureBody
- KtWhenEntry
So there's no need to check anything else
#KT-14986 Fixed
#KT-14483 Fixed
7 lines
146 B
Plaintext
Vendored
7 lines
146 B
Plaintext
Vendored
fun foo() {
|
|
class A {
|
|
// it's not a statement, while it has a block expression as an ancestor
|
|
val w = 1.try <caret>
|
|
}
|
|
}
|