Files
kotlin-fork/compiler/testData/codegen/bytecodeText/nullCheckOptimization/deterministicNotNullChecks.kt
T
2020-10-22 10:51:20 +03:00

31 lines
1.2 KiB
Kotlin
Vendored

// FILE: test/CallableDescriptor.java
// IGNORE_BACKEND_FIR: JVM_IR
// Here FIR adds implicit NOT_NULL cast for `origin`, resulting in an assertion being added,
// which is the correct (yet mismatching) behavior, according to https://youtrack.jetbrains.com/issue/KT-35656
// JVM_IR:
// Here in 'original in emptySet<D>()' T = '@EnhancedNullability CallableDescriptor' is inferred for 'Iterable<T>.contains(T)'.
// Using value of '@EnhancedNullability CallableDescriptor' type where '@EnhancedNullability CallableDescriptor' is expected
// doesn't cause a null check.
package test;
import org.jetbrains.annotations.NotNull;
public interface CallableDescriptor {
@NotNull
CallableDescriptor getOriginal();
}
// FILE: test/k.kt
package test
fun <D : CallableDescriptor> D.overriddenTreeUniqueAsSequenceA(): Boolean {
return original in emptySet<D>()
}
// TODO: in fact, there should be an assertion, but it's missing because of https://youtrack.jetbrains.com/issue/KT-24210.
// (This test's aim is not to check whether or not the assertion is generated, but to ensure that the behavior is deterministic.)
// 0 checkExpressionValueIsNotNull
// 0 checkNotNullExpressionValue