FIR: add example 2 from KT-49925 (fails yet)

This commit is contained in:
Mikhail Glukhikh
2021-12-21 13:23:53 +03:00
committed by teamcity
parent dde4c46df7
commit 3f02309dad
5 changed files with 88 additions and 0 deletions
@@ -0,0 +1,46 @@
FILE: buildSetWithVisitor.kt
public abstract class AnyVisitor : R|kotlin/Any| {
public constructor(): R|AnyVisitor| {
super<R|kotlin/Any|>()
}
public abstract fun visit(arg: R|Wrapper|): R|kotlin/Unit|
}
public final class Wrapper : R|kotlin/Any| {
public constructor(tag: R|kotlin/String|): R|Wrapper| {
super<R|kotlin/Any|>()
}
public final val tag: R|kotlin/String| = R|<local>/tag|
public get(): R|kotlin/String|
}
public final fun R|Wrapper|.accept(visitor: R|AnyVisitor|): R|kotlin/Unit| {
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>| {
^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> {
R|<local>/wrapper|.R|/accept|(object : R|AnyVisitor| {
private constructor(): R|<anonymous>| {
super<R|AnyVisitor|>()
}
public final override fun visit(arg: R|Wrapper|): R|kotlin/Unit| {
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableSet.add: R|kotlin/Boolean|>|(R|<local>/arg|.R|/Wrapper.tag|)
}
}
)
}
)
}
public final fun foo(wrapper: R|Wrapper|): R|kotlin/collections/Set<kotlin/String>| {
^foo 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|kotlin/let|<R|Wrapper|, R|kotlin/Unit|>(<L> = let@fun <anonymous>(it: R|Wrapper|): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableSet.add: R|kotlin/Boolean|>|(R|<local>/it|.R|/Wrapper.tag|)
}
)
}
)
}
@@ -0,0 +1,24 @@
abstract class AnyVisitor {
abstract fun visit(arg: Wrapper)
}
class Wrapper(val tag: String)
fun Wrapper.accept(visitor: AnyVisitor) {
visitor.visit(this)
}
fun bar(wrapper: Wrapper) = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildSet<!> {
wrapper.accept(object : AnyVisitor() {
override fun visit(arg: Wrapper) {
add(arg.tag)
}
})
}
fun foo(wrapper: Wrapper) = buildSet {
wrapper.let {
add(it.tag)
}
}