inline fun finalizeDocFrag(consumer: TagConsumer, block: Any?) : R { if (this.consumer !== consumer) { throw IllegalArgumentException("Wrong exception") } val tmp = consumer is HTMLStreamBuilder println("$tmp") println("consumer's class: ${consumer::class.simpleName}") println("R's class: ${R::class.simpleName}") if(block !== null) { if (String is R) return (this as Tag).visitAndFinalize(consumer, block as (Tag.() -> Unit)) else return finalize(consumer as TagConsumer, block as (TagConsumer.() -> HTMLElement)) as R } return consumer.finalize() }