arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2408.10804cs.PLcs.SE
收藏

Kotlin 的类型系统(也)是不健全的

Kotlin's Type System is (Also) Unsound

Elad Kinsbruner, Hila Peleg, Shachar Itzhaky

AI总结:

针对Kotlin类型系统,利用声明点变型特性构造违规代码片段,证明其不健全性,并分析成因及修复方案。

摘要:

类型系统的健全性是一个基本属性,它保证在运行时不会对某个值执行该值不支持的操作。健全类型系统的类型检查器应当对每个类型错误发出警告。尽管健全性对于许多实际应用来说是一个理想的属性,但在2016年,Amin和Tate首次为两种主要的工业语言——Java和Scala——提出了不健全性证明。该证明依赖于使用点变型和隐式空值。\n我们为Kotlin(另一种新兴的工业语言)提出了一个不健全性证明,该证明依赖于一种先前未知的语言特性组合,这种组合是不健全的。Kotlin没有隐式空值,这意味着Amin和Tate的证明不适用于Kotlin。我们的新证明是一个违规的代码片段,利用了Kotlin的声明点变型规范,并且不需要隐式空值。\n我们完整地展示了这个健全性的反例,并详细解释了每一步。最后,我们对导致此问题的具体语言特性进行了深入讨论,以及如何修补Kotlin编译器以修复此问题。

英文摘要:

Soundness of a type system is a fundemental property that guarantees that no operation that is not supported by a value will be performed on that value at run time. A type checker for a sound type system is expected to issue a warning on every type error. While soundness is a desirable property for many practical applications, in 2016, Amin and Tate presented the first unsoundness proof for two major industry languages: Java and Scala. This proof relied on use-site variance and implicit null values. We present an unsoundness proof for Kotlin, another emerging industry language, which relies on a previously unknown unsound combination of language features. Kotlin does not have implicit null values, meaning that the proof by Amin and Tate would not work for Kotlin. Our new proof, which is an infringing code snippet, utilizes Kotlin's \emph{declaration-site} variance specification and does not require implicit null values. We present this counterexample to soundness in full along with detailed explanations of every step. Finally, we present a thorough discussion on precisely which language features cause this issue, as well as how Kotlin's compiler can be patched to fix it.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑