[FIR] Fix resolving of single underscore _

Now compiler throws `UNRESOLVED_REFERENCE` here:

```
val boo = { _: Exception -> `_`.stackTrace }
```
This commit is contained in:
Ivan Kochurkin
2021-07-23 18:18:13 +03:00
committed by Space
parent 8bfaa39a5c
commit 1a40164ef0
14 changed files with 87 additions and 44 deletions
@@ -1,16 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.config.LanguageVersionSettings
@NoMutableState
class FirLanguageSettingsComponent(val languageVersionSettings: LanguageVersionSettings) : FirSessionComponent
private val FirSession.languageSettingsComponent: FirLanguageSettingsComponent by FirSession.sessionComponentAccessor()
val FirSession.languageVersionSettings: LanguageVersionSettings
get() = languageSettingsComponent.languageVersionSettings
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames.UNDERSCORE_FOR_UNUSED_VAR
class BodyResolveContext(
val returnTypeCalculator: ReturnTypeCalculator,
@@ -612,7 +613,9 @@ class BodyResolveContext(
valueParameter: FirValueParameter,
f: () -> T
): T {
storeVariable(valueParameter)
if (!valueParameter.name.isSpecial || valueParameter.name != UNDERSCORE_FOR_UNUSED_VAR) {
storeVariable(valueParameter)
}
return withContainer(valueParameter, f)
}