Hacker News new | ask | show | jobs
by joe_fishfish 309 days ago
In Kotlin this would already be a compile error, no need for another annotation.
1 comments

Yeah, sure, and thankfully everyone has already switched all their teams to superior languages

Anyway, I believe what you're referring to is the "?" syntax that annotates types in Kotlin but doesn't help the resulting bytecode, which means that every single library ever would need to convert to kotlin to benefit

  fun doit() : java.io.InputStream? { return null }
  kotlinc test.kt
  javap -c test.class
  public final java.io.InputStream doit();
    Code:
       0: aconst_null
       1: areturn
So even they didn't have the courtesy of marking the result of a known Optional result as Optional<java.io.InputStream> when interfacing with the existing Java ecosystem