Simplify test case on deterministic null-checks
This commit is contained in:
+5
-94
@@ -1,109 +1,20 @@
|
|||||||
// FILE: test/DeclarationDescriptor.java
|
|
||||||
|
|
||||||
package test;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface DeclarationDescriptor {
|
|
||||||
@NotNull
|
|
||||||
DeclarationDescriptor getOriginal();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
DeclarationDescriptor getContainingDeclaration();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: test/DeclarationDescriptorWithVisibility.java
|
|
||||||
package test;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface DeclarationDescriptorWithVisibility extends DeclarationDescriptor {
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: test/DeclarationDescriptorWithSource.java
|
|
||||||
package test;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface DeclarationDescriptorWithSource extends DeclarationDescriptor {
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
DeclarationDescriptorWithSource getOriginal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: test/DeclarationDescriptorNonRoot.java
|
|
||||||
package test;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface DeclarationDescriptorNonRoot extends DeclarationDescriptorWithSource {
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: test/CallableDescriptor.java
|
// FILE: test/CallableDescriptor.java
|
||||||
package test;
|
package test;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
public interface CallableDescriptor {
|
||||||
|
|
||||||
public interface CallableDescriptor extends DeclarationDescriptorWithVisibility, DeclarationDescriptorNonRoot {
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
|
||||||
CallableDescriptor getOriginal();
|
CallableDescriptor getOriginal();
|
||||||
|
|
||||||
@NotNull
|
|
||||||
Collection<? extends CallableDescriptor> getOverriddenDescriptors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE: test/k.kt
|
// FILE: test/k.kt
|
||||||
package test
|
package test
|
||||||
|
|
||||||
fun <D : CallableDescriptor> D.overriddenTreeUniqueAsSequenceA(useOriginal: Boolean): Sequence<D> {
|
fun <D : CallableDescriptor> D.overriddenTreeUniqueAsSequenceA(): Boolean {
|
||||||
val set = hashSetOf<D>()
|
return original in emptySet<D>()
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
fun D.doBuildOverriddenTreeAsSequence(): Sequence<D> {
|
|
||||||
return with(if (useOriginal) original as D else this) {
|
|
||||||
if (original in set)
|
|
||||||
emptySequence()
|
|
||||||
else {
|
|
||||||
emptySequence()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return doBuildOverriddenTreeAsSequence()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <D : CallableDescriptor> D.overriddenTreeUniqueAsSequenceB(useOriginal: Boolean): Sequence<D> {
|
// TODO: in fact, there should be an assertion, but it's missing because of https://youtrack.jetbrains.com/issue/KT-24210.
|
||||||
val set = hashSetOf<D>()
|
// (This test's aim is not to check whether or not the assertion is generated, but to ensure that the behavior is deterministic.)
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
fun D.doBuildOverriddenTreeAsSequence(): Sequence<D> {
|
|
||||||
return with(if (useOriginal) original as D else this) {
|
|
||||||
if (original in set)
|
|
||||||
emptySequence()
|
|
||||||
else {
|
|
||||||
emptySequence()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return doBuildOverriddenTreeAsSequence()
|
|
||||||
}
|
|
||||||
|
|
||||||
// @KKt.class:
|
|
||||||
// 0 checkExpressionValueIsNotNull
|
// 0 checkExpressionValueIsNotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user