Files
kotlin-fork/analysis/analysis-api/testData/components/symbolDeclarationRenderer/renderDeclaration/contextReceiver.kt
T
Marco Pennekamp 2cd16f055a [AA] KT-55098 Render context receivers in declarations & function types
- `context(...)` is a modifier that must precede annotations and other
  modifiers, so for declarations it is rendered in
  `renderAnnotationsAndModifiers`.
- Ignore `@ContextFunctionTypeParams` in the annotation list of FE10
  types, as the annotation is an implementation detail of context
  receivers in K1 and shouldn't be rendered.

^KT-55098 fixed
2022-12-06 17:43:30 +00:00

37 lines
651 B
Kotlin
Vendored

interface Context1
interface Context2<A> {
fun getContextElement(): A
}
class Context2Impl<A>(val value: A) : Context2<A> {
override fun getContextElement(): A = value
}
context(Int, String)
class A {
context(Double)
constructor(int: Int) {}
}
context(Context1, c2@Context2<String>)
class B {
override fun toString(): String = getContextElement()
}
context(Context2<A>)
class C<A> {
val a: A
get() = getContextElement()
}
context(Context1)
@Deprecated("Use `B` instead.")
class D
context(b@B, `fun`@A)
fun foo() = Unit
context(Context2<C<String>>)
fun bar() = with (Context2Impl(getContextElement().a)) { C() }