Kotlin 1.3.11 has broken null-safety?

  • A+
Category:Languages
fun handle() : String {     null?.let { return "Ololo"} }  val result = handle() result.trim() // kotlin.TypeCastException: null cannot be cast to non-null type kotlin.CharSequence 

Any ideas why null-safe Kotlin function return null?

 


It's a bug caused by introducing contracts for the standard functions let, run, apply, also in Kotlin 1.3.

The fix is targeted to the version 1.3.20. See KT-28061 for details.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: