diff --git a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt index 031dd4456d..7fff96de03 100644 --- a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt +++ b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt @@ -33,7 +33,8 @@ fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set> val imports = "import ${subclass.qualifiedName}" + if (typeUpperBounds.isEmpty()) "" else typeUpperBounds.joinToString("\nimport ", "\nimport ") val subtype = "${subclass.simpleName}${if (typeUpperBounds.isEmpty()) "" else "<${typeUpperBounds.joinToString() { (it.classifier as KClass<*>).simpleName!! }}>"}" val code = "@PreviewFeature\ninline fun ${kclass.simpleName}.as${subclass.simpleName}(): $subtype? = this as? $subtype\n" + - "@PreviewFeature\ninline fun ${kclass.simpleName}.require${subclass.simpleName}(): $subtype = this as $subtype" + "@PreviewFeature\ninline fun ${kclass.simpleName}.require${subclass.simpleName}(): $subtype = this as $subtype\n" + + "@PreviewFeature\ninline fun ${kclass.simpleName}.when${subclass.simpleName}(block: (${subclass.simpleName}) -> T): $subtype = as${subclass.simpleName}() ?.let(block)" imports to code } } @@ -65,4 +66,4 @@ fun main() { // printlnInstanceSubclassesFuns(InputMedia::class) // printlnInstanceSubclassesFuns(Poll::class) // printlnInstanceSubclassesFuns(Update::class) -} \ No newline at end of file +}