I don't need and want any optional there
# announcements
p
I don't need and want any optional there
d
You don't have an "optional". The parameter is not optional. All that the intrinsic check does is make the error message explicit ("parameter X was not expected to be null") instead of a blank NullPointerException. There is no added value in forcing the compiler to remove this check.
p
I don't want to apply this rule on my entire project 😞
I wish I could use an annotation to tell the compiler to not add these checks on this specific function or class.
d
Why?
p
because my project is big? I don't want to remove all these checks just because a single function is using it.
d
I mean, why do you not want these checks?
s
Write the function in java 😛
p
omg no
I don't understand why
FloatArray
needs to be checked if it is only called by Kotlin sources.
d
1. The compiler cannot verify that it's only called by Kotlin 2. Separate compilation makes it so that you have no guarantees on what you will be called with.
p
that's understandable, couldn't a annotation tell the compiler to not accept this method of being called from a Java code and not include these checks?
d
Java sources are compiled by javac, not kotlinc. Kotlin has no influence on what happens in Java.
s
In theory it could omit the check by an annotation, sure. But the compiler has no such support. Probably because there is no evidence that the
Intrinsics.*
call has non-negligible impact on the performance.
p
yes, the Kotlin linter can make the function not available in Java, I am very ignorant on this subject matter
d
What does the linter have to do with it? I am not sure I follow. And yes, the performance impact is likely negligible. The static method is almost guaranteed to be inlined by the JVM and then the JVM will eliminate any null checks it would otherwise insert by itself. So in the end you get pretty much the same machine code, except you now have a meaningful error message.