Skip to content

Conversation

@Godin
Copy link
Member

@Godin Godin commented Jan 5, 2019

@Godin Godin added this to the 0.8.3 milestone Jan 5, 2019
@Godin Godin self-assigned this Jan 5, 2019
@Godin Godin requested a review from marchof January 5, 2019 02:00
@marchof marchof merged commit 45efe1e into master Jan 8, 2019
@marchof marchof deleted the filter_kotlin_not_null_operator branch January 8, 2019 19:47
@Godin
Copy link
Member Author

Godin commented Jan 9, 2019

BTW IMO there is no need to generate explicit null-check in cases such as

fun example(x: String?) {
  val y:Int  = x!!.length
  // ...
}

because invokevirtual anyway will throw NPE

         0: aload_1
         1: dup
         2: ifnonnull     8
         5: invokestatic  #12                 // Method kotlin/jvm/internal/Intrinsics.throwNpe:()V
         8: invokevirtual #18                 // Method java/lang/String.length:()I
        11: istore_2

while definitely useful in cases such as

fun example(x: String?) {
  val y: String = x!!
  // ...
}

@goodwinnk maybe this is something what can be improved in Kotlin compiler?

@goodwinnk
Copy link
Contributor

@Godin There's a plan to unify different null checks in Kotlin in favor to simply throwing Java NPE: https://youtrack.jetbrains.com/issue/KT-22275

@Godin
Copy link
Member Author

Godin commented Jan 28, 2019

@goodwinnk good to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants