/tmp/duangsuse.sock
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/index.html 原来 Kotlin 里已经有 Iterable.toMap 了,就是 associate…… 还有 associateBy…… histogram 也早就有了,就是 groupBy…… 原来 partition 只是特殊化的 groupBy 啊…… 还有 chunked, windowed 这种高级操作…… 还可以用 onEach,许多 method 还有 withIndex…
突然对 ParserKt 的代码质量很失望,草,必须重构了
原来那都是我自己所谓的叫法,什么俩重载的 toMap 居然是 associate, associateBy、hist 居然是 groupBy…… #Kotlin
ParserKt 式的流架构可以说是原创,但存在着一个黑点
我也不确定它到底在多大程度上比 Kotlin sequences 处理能力强
原来那都是我自己所谓的叫法,什么俩重载的 toMap 居然是 associate, associateBy、hist 居然是 groupBy…… #Kotlin
ParserKt 式的流架构可以说是原创,但存在着一个黑点
我也不确定它到底在多大程度上比 Kotlin sequences 处理能力强
/tmp/duangsuse.sock
突然对 ParserKt 的代码质量很失望,草,必须重构了 原来那都是我自己所谓的叫法,什么俩重载的 toMap 居然是 associate, associateBy、hist 居然是 groupBy…… #Kotlin ParserKt 式的流架构可以说是原创,但存在着一个黑点 我也不确定它到底在多大程度上比 Kotlin sequences 处理能力强
Kotlin 真的好厉害…… groupBy 都能抽象出一个基于
keyOf 的 Grouping 来…… 连 Haskell 里都没见过这样的集合操作> Task :parserkt-util:compileKotlinJs FAILED辣鸡 Kotlinc 又出错了
e: java.lang.StackOverflowError
at kotlin.collections.ArraysKt___ArraysKt.map(_Arrays.kt:8888)
at org.jetbrains.kotlin.name.FqNameUnsafe.pathSegments(FqNameUnsafe.java:158)
at org.jetbrains.kotlin.name.FqName.pathSegments(FqName.java:98)
at org.jetbrains.kotlin.descriptors.FindClassInModuleKt.findClassifierAcrossModuleDependencies(findClassInModule.kt:24)
at org.jetbrains.kotlin.descriptors.FindClassInModuleKt.findClassAcrossModuleDependencies(findClassInModule.kt:40)
/tmp/duangsuse.sock
> Task :parserkt-util:compileKotlinJs FAILED e: java.lang.StackOverflowError at kotlin.collections.ArraysKt___ArraysKt.map(_Arrays.kt:8888) at org.jetbrains.kotlin.name.FqNameUnsafe.pathSegments(FqNameUnsafe.java:158) at org.jetbra…
我通过 undo last commit 逐个排查修改文件后已经找到了原因,的确是 inline type parameter 的问题
作为一个 Kotlin 程序员的爱心…… 虽然此 bug 有 workaround,但我还是把它提交给 JetBrains 的好
现在正在撰写最小 problem file
作为一个 Kotlin 程序员的爱心…… 虽然此 bug 有 workaround,但我还是把它提交给 JetBrains 的好
现在正在撰写最小 problem file
[duangsuse@susepc tmp]$ kotlinc-js SOE.kt -output a.js成功重现 bug,正在简化问题文件
exception: java.lang.StackOverflowError
at org.jetbrains.kotlin.js.translate.expression.ExpressionVisitor.getPrimitiveClass(ExpressionVisitor.java:303)
inline fun <reified T: Any> T.compareUsing(other: Any?, crossinline compare: T.(T) -> Boolean): Boolean {
if (this === other) return true
return other is T && compare(other)
}
interface Animal<FOOD> where FOOD: Comparable<FOOD> {
val food: FOOD
}
abstract class BaseAnimal<FOOD>(override val food: FOOD): Animal<FOOD> where FOOD: Comparable<FOOD> {
override fun equals(other: Any?) = compareUsing(other) { food == it.food }
}
这是基本问题输入,即便我不用 intersection upper-bound 也是一样inline fun <reified T> T.causeBug() {}
interface SomeToImplement<SOME_TVAR>
interface SomeInterface<T> where T: SomeToImplement<T> {
val field: T
}
abstract class SomeChild<T>(override val field: T): SomeInterface<T> where T: SomeToImplement<T> {
fun op() = causeBug()
}
即便 causeBug 的 T 不是 receiver 也是一样只有在
SOME_TVAR 包含对继承自自己的 Type 的引用时候才会引发无尽递归T: SomeToImplement<Int> 则不会引起 buginline fun <reified T> T.causeBug() {}
interface SomeToImplement<SELF_TVAR>
interface SomeInterface<T> where T: SomeToImplement<T>
abstract class SomeChild<T>: SomeInterface<T> where T: SomeToImplement<T> {
fun op() = causeBug()
}提交了这个 bug 就去睡觉~ 但愿能尽早修复
StackOverflowException when using reified recursive bound for type parameter in Kotlin2Js
https://youtrack.jetbrains.com/issue/KT-37128
提交了
StackOverflowException when using reified recursive bound for type parameter in Kotlin2Js
https://youtrack.jetbrains.com/issue/KT-37128
提交了
Forwarded from Deleted Account
object Yes {
fun main(vararg args: String) {
while(true) println(args.firstOrNull() ?: "y")
}
}(迫真)buffer 什么的就算了
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-dsl-marker/index.html
结果
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-builder-inference/index.html
无法理解,表述太复杂,看示例是能从
@DslMarker annotation class HtmlTag
@HtmlTag class TagHtml()
@HtmlTag class TagHead() 结果
html { head { head {} } } 同名 member 就可以 closest one wins 吗……https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-builder-inference/index.html
无法理解,表述太复杂,看示例是能从
fun <T> (op: @DslMarker Receiver<T>.() -> Unit) 这样的 function argument 推导出 T 一样Kotlin
DslMarker - Kotlin Programming Language