Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to denote a T! platform type in Kotlin only, without resorting to using Java

Tags:

kotlin

Is there any way in pure Kotlin to produce a T! type as opposed to T or T? - in other words, is the T! type denotable in Kotlin? These obviously don't work:

val t: T! = ...
fun f(): T! = ...

I'm open to (reliable) hacks.

like image 912
Lukas Eder Avatar asked Sep 06 '25 19:09

Lukas Eder


1 Answers

Not currently. There was a proposal for this that was open for a few years and then declined some months after you asked this question: https://github.com/Kotlin/KEEP/issues/82.

like image 102
Chris Povirk Avatar answered Sep 08 '25 12:09

Chris Povirk