Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter for Kotlin not-null assertion operator #815

Merged
merged 8 commits into from
Jan 8, 2019

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 added this to To Do in Filtering via automation Jan 5, 2019
@Godin Godin added this to Implementation in Current work items via automation Jan 5, 2019
@Godin Godin requested a review from marchof January 5, 2019 02:00
@Godin Godin moved this from Implementation to Review in Current work items Jan 5, 2019
@marchof marchof merged commit 45efe1e into master Jan 8, 2019
Filtering automation moved this from To Do to Done Jan 8, 2019
Current work items automation moved this from Review to Done 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
Filtering
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants