Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

IllegalStateException is thrown when shouldBeEquivalentTo comparison fails #227

Open
beyonnex-qa opened this issue Feb 23, 2024 · 0 comments

Comments

@beyonnex-qa
Copy link

In a test, I'm using shouldBeEquivalentTo to compare two objects from the same class. It works fine when the two objects are equivalent, but when they are not the following exception is thrown:

java.lang.IllegalStateException: Cannot infer visibility for inherited open fun clone(): kotlin.Any defined in java.util.LinkedHashSet[JavaMethodDescriptor@f882465]

	at kotlin.reflect.jvm.internal.impl.descriptors.runtime.components.RuntimeErrorReporter.reportCannotInferVisibility(RuntimeErrorReporter.kt:31)
	at kotlin.reflect.jvm.internal.impl.load.java.components.DescriptorResolverUtils$1$1.invoke(DescriptorResolverUtils.java:79)
	at kotlin.reflect.jvm.internal.impl.load.java.components.DescriptorResolverUtils$1$1.invoke(DescriptorResolverUtils.java:76)
	at kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil.resolveUnknownVisibilityForMember(OverridingUtil.java:913)
	at kotlin.reflect.jvm.internal.impl.load.java.components.DescriptorResolverUtils$1.addFakeOverride(DescriptorResolverUtils.java:76)
	at kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil.createAndBindFakeOverride(OverridingUtil.java:741)
	at kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil.createAndBindFakeOverrides(OverridingUtil.java:583)
	at kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil.generateOverridesInFunctionGroup(OverridingUtil.java:504)
	at kotlin.reflect.jvm.internal.impl.load.java.components.DescriptorResolverUtils.resolveOverrides(DescriptorResolverUtils.java:70)
	at kotlin.reflect.jvm.internal.impl.load.java.components.DescriptorResolverUtils.resolveOverridesForNonStaticMembers(DescriptorResolverUtils.java:46)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaClassMemberScope.addFunctionFromSupertypes(LazyJavaClassMemberScope.kt:366)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaClassMemberScope.computeNonDeclaredFunctions(LazyJavaClassMemberScope.kt:325)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$functions$1.invoke(LazyJavaScope.kt:123)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$functions$1.invoke(LazyJavaScope.kt:118)
	at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
	at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope.getContributedFunctions(LazyJavaScope.kt:273)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaClassMemberScope.getContributedFunctions(LazyJavaClassMemberScope.kt:865)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope.computeDescriptors(LazyJavaScope.kt:378)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$allDescriptors$1.invoke(LazyJavaScope.kt:64)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$allDescriptors$1.invoke(LazyJavaScope.kt:63)
	at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:408)
	at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:527)
	at kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope.getContributedDescriptors(LazyJavaScope.kt:357)
	at kotlin.reflect.jvm.internal.impl.resolve.scopes.ResolutionScope$DefaultImpls.getContributedDescriptors$default(ResolutionScope.kt:50)
	at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.getMembers(KDeclarationContainerImpl.kt:58)
	at kotlin.reflect.jvm.internal.KClassImpl$Data$declaredNonStaticMembers$2.invoke(KClassImpl.kt:162)
	at kotlin.reflect.jvm.internal.KClassImpl$Data$declaredNonStaticMembers$2.invoke(KClassImpl.kt:162)
	at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:93)
	at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:32)
	at kotlin.reflect.jvm.internal.KClassImpl$Data.getDeclaredNonStaticMembers(KClassImpl.kt:162)
	at kotlin.reflect.full.KClasses.getDeclaredMemberProperties(KClasses.kt:162)
	at org.amshove.kluent.EquivalencyKt.toStructuredString(Equivalency.kt:202)
	at org.amshove.kluent.EquivalencyKt.toStructuredString$default(Equivalency.kt:154)
	at org.amshove.kluent.EquivalencyKt.toStructuredString(Equivalency.kt:214)
	at org.amshove.kluent.EquivalencyKt.toStructuredString$default(Equivalency.kt:154)
	at org.amshove.kluent.EquivalencyKt.assertEquivalency(Equivalency.kt:255)
	at org.amshove.kluent.EquivalencyKt.shouldBeEquivalentTo(Equivalency.kt:14)
	at org.amshove.kluent.EquivalencyKt.shouldBeEquivalentTo$default(Equivalency.kt:13)
	

This is problematic as I would expect the test to fail and show the differences between objects.

I'm currently using Kotlin 1.9.10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant