FIR: copy builder inference session when creating snapshot for locals
This commit fixes one builder inference case from KT-49925
This commit is contained in:
committed by
teamcity
parent
3f02309dad
commit
f53cd22253
+2
-2
@@ -19,8 +19,8 @@ FILE: buildSetWithVisitor.kt
|
|||||||
public final fun R|Wrapper|.accept(visitor: R|AnyVisitor|): R|kotlin/Unit| {
|
public final fun R|Wrapper|.accept(visitor: R|AnyVisitor|): R|kotlin/Unit| {
|
||||||
R|<local>/visitor|.R|/AnyVisitor.visit|(this@R|/accept|)
|
R|<local>/visitor|.R|/AnyVisitor.visit|(this@R|/accept|)
|
||||||
}
|
}
|
||||||
public final fun bar(wrapper: R|Wrapper|): R|kotlin/collections/Set<ERROR CLASS: Cannot infer argument for type parameter E>| {
|
public final fun bar(wrapper: R|Wrapper|): R|kotlin/collections/Set<kotlin/String>| {
|
||||||
^bar <CS errors: kotlin/collections/buildSet>#<R|ERROR CLASS: Cannot infer argument for type parameter E|>(<L> = buildSet@fun R|kotlin/collections/MutableSet<ERROR CLASS: Cannot infer argument for type parameter E>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
^bar R|kotlin/collections/buildSet|<R|kotlin/String|>(<L> = buildSet@fun R|kotlin/collections/MutableSet<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
R|<local>/wrapper|.R|/accept|(object : R|AnyVisitor| {
|
R|<local>/wrapper|.R|/accept|(object : R|AnyVisitor| {
|
||||||
private constructor(): R|<anonymous>| {
|
private constructor(): R|<anonymous>| {
|
||||||
super<R|AnyVisitor|>()
|
super<R|AnyVisitor|>()
|
||||||
|
|||||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ fun Wrapper.accept(visitor: AnyVisitor) {
|
|||||||
visitor.visit(this)
|
visitor.visit(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(wrapper: Wrapper) = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildSet<!> {
|
fun bar(wrapper: Wrapper) = buildSet {
|
||||||
wrapper.accept(object : AnyVisitor() {
|
wrapper.accept(object : AnyVisitor() {
|
||||||
override fun visit(arg: Wrapper) {
|
override fun visit(arg: Wrapper) {
|
||||||
add(arg.tag)
|
add(arg.tag)
|
||||||
|
|||||||
+8
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.InaccessibleImplicitReceiverValue
|
|||||||
import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
|
import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowAnalyzerContext
|
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowAnalyzerContext
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.PersistentFlow
|
import org.jetbrains.kotlin.fir.resolve.dfa.PersistentFlow
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.inference.FirBuilderInferenceSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.FirCallCompleter
|
import org.jetbrains.kotlin.fir.resolve.inference.FirCallCompleter
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.FirDelegatedPropertyInferenceSession
|
import org.jetbrains.kotlin.fir.resolve.inference.FirDelegatedPropertyInferenceSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.FirInferenceSession
|
import org.jetbrains.kotlin.fir.resolve.inference.FirInferenceSession
|
||||||
@@ -348,6 +349,13 @@ class BodyResolveContext(
|
|||||||
containingClass = this@BodyResolveContext.containingClass
|
containingClass = this@BodyResolveContext.containingClass
|
||||||
replaceTowerDataContext(this@BodyResolveContext.towerDataContext)
|
replaceTowerDataContext(this@BodyResolveContext.towerDataContext)
|
||||||
anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext)
|
anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext)
|
||||||
|
// Looks like we should copy this session only for builder inference to be able
|
||||||
|
// to use information from local class inside it.
|
||||||
|
// However, we should not copy other kinds of inference sessions,
|
||||||
|
// otherwise we can "inherit" type variables from there provoking inference problems
|
||||||
|
if (this@BodyResolveContext.inferenceSession is FirBuilderInferenceSession) {
|
||||||
|
inferenceSession = this@BodyResolveContext.inferenceSession
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// withElement PUBLIC API
|
// withElement PUBLIC API
|
||||||
|
|||||||
Vendored
-2
@@ -1,6 +1,4 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER on buildList calls (E)
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
fun foo1() {
|
fun foo1() {
|
||||||
buildList {
|
buildList {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER on buildList call (E)
|
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
|
||||||
class TowerDataElementsForName() {
|
class TowerDataElementsForName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user