interface KtScope { fun getAllNames(): Set } inline fun buildSet(@BuilderInference builderAction: MutableSet.() -> Unit): Set { return null!! } inline fun withValidityAssertion(action: () -> R): R { return action() } class KtFirCompositeScope(val subScopes: List) { fun getAllNames(): Set = withValidityAssertion { buildSet { subScopes.flatMapTo(this) { it.getAllNames() } } } }