I just had a thought about a possibly useful exten...
# language-proposals
a
I just had a thought about a possibly useful extension of the Delegation feature. This is mostly in service of testing, but it would be handy to have a keyword (
throwing
?) where the compiler auto-generates interface implementations that just
throw
, but that you have an option to override. This would basically be for creating fakes on massive interfaces without reflection proxying. Eg:
Copy code
class FakeConnection : java.sql.Connection by throwing {
  override fun prepareCall(sql: String) {
    // ... some assertion.
  } 
}
I definitely see potential for abuse, but in a testing context super handy.
1
j
If you're on the JVM you can do this with a j.l.r.Proxy
🆒 1