class Param {
  constructor() /* primary */ {
    super/*Any*/()
    /* <init>() */

  }

}

class C {
  constructor() /* primary */ {
    super/*Any*/()
    /* <init>() */

  }

  val c: Int
    field = 42
    get

}

class R {
  constructor() /* primary */ {
    super/*Any*/()
    /* <init>() */

  }

  val r: Int
    field = 42
    get

}

fun R.f1(<this>: C, g: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3<C, R, Param, Unit>) {
  g.invoke(p1 = <this>, p2 = <this>, p3 = Param())
}

fun f2(<this>: C, g: @ContextFunctionTypeParams(count = 1) Function2<C, Param, Unit>) {
  g.invoke(p1 = <this>, p2 = Param())
}

fun R.f3(<this>: C, g: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2<C, R, Unit>) {
  g.invoke(p1 = <this>, p2 = <this>)
}

fun f4(<this>: C, g: @ContextFunctionTypeParams(count = 1) Function1<C, Unit>) {
  g.invoke(p1 = <this>)
}

fun test() {
  val lf1: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3<C, R, Param, Unit> = local fun R.<anonymous>(<this>: C, <anonymous parameter 0>: Param) {
    $this$null.<get-r>() /*~> Unit */
    <this>.<get-c>() /*~> Unit */
  }

  val lf2: @ContextFunctionTypeParams(count = 1) Function2<C, Param, Unit> = local fun <anonymous>(<this>: C, <anonymous parameter 0>: Param) {
    <this>.<get-c>() /*~> Unit */
  }

  val lf3: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2<C, R, Unit> = local fun R.<anonymous>(<this>: C) {
    $this$null.<get-r>() /*~> Unit */
    <this>.<get-c>() /*~> Unit */
  }

  val lf4: @ContextFunctionTypeParams(count = 1) Function1<C, Unit> = local fun <anonymous>(<this>: C) {
    <this>.<get-c>() /*~> Unit */
  }

  with<C, Unit>(receiver = C(), block = local fun C.<anonymous>() {
    with<R, Unit>(receiver = R(), block = local fun R.<anonymous>() {
      $this$with.f1(<this> = $this$with, g = lf1)
      $this$with.f1(<this> = $this$with, g = local fun R.<anonymous>(<this>: C, <anonymous parameter 0>: Param) {
        $this$f1.<get-r>() /*~> Unit */
        $this$with.<get-c>() /*~> Unit */
      }
)
      f2(<this> = $this$with, g = lf2)
      f2(<this> = $this$with, g = local fun <anonymous>(<this>: C, <anonymous parameter 0>: Param) {
        $this$with.<get-c>() /*~> Unit */
      }
)
      $this$with.f3(<this> = $this$with, g = lf3)
      $this$with.f3(<this> = $this$with, g = local fun R.<anonymous>(<this>: C) {
        $this$f3.<get-r>() /*~> Unit */
        $this$with.<get-c>() /*~> Unit */
      }
)
      f4(<this> = $this$with, g = lf4)
      f4(<this> = $this$with, g = local fun <anonymous>(<this>: C) {
        $this$with.<get-c>() /*~> Unit */
      }
)
    }
)
  }
)
}
