Not 100% percent sure, if this is a bug, but feels...
# announcements
s
Not 100% percent sure, if this is a bug, but feels like one. When using a
var
for delegation only the first initial value is used.
Copy code
class DelegateTest {
  @Test fun `Swapping delegates`() {
    val dc = DelegatingCallable(EmptyCallable)
    assertThat(dc.call()).isEqualTo("")

    dc.c = Callable<String> { "obj" }
    assertThat(dc.call()).isEqualTo("obj")
  }
}

class DelegatingCallable(var c: Callable<String>) : Callable<String> by c

object EmptyCallable : Callable<String> {
  override fun call() = ""
}