From 03681a5c2d15125afad7055af15bec0f14143814 Mon Sep 17 00:00:00 2001 From: Oleg Golberg Date: Sun, 25 Feb 2024 20:50:25 -0500 Subject: [PATCH] Updated fix for invokeinterface The previous fix for invokeinterface was broken, fixing it properly --- .../main/kotlin/com/toasttab/expediter/Expediter.kt | 12 ++++-------- .../expediter/test/caller/CallerNegative.java | 5 +++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/main/kotlin/com/toasttab/expediter/Expediter.kt b/core/src/main/kotlin/com/toasttab/expediter/Expediter.kt index 702f4d8..1cde29a 100644 --- a/core/src/main/kotlin/com/toasttab/expediter/Expediter.kt +++ b/core/src/main/kotlin/com/toasttab/expediter/Expediter.kt @@ -184,16 +184,12 @@ private class MemberWithDeclaringType( ) private fun ResolvedTypeHierarchy.CompleteTypeHierarchy.filterToAccessType(access: MemberAccess): Sequence { - return if (access !is MemberAccess.MethodAccess || - access.accessType == MethodAccessType.VIRTUAL || - access.accessType == MethodAccessType.STATIC || - (access.accessType == MethodAccessType.SPECIAL && !access.ref.isConstructor()) - ) { - // fields and methods, except for constructors can be declared on any type in the hierarchy - allTypes - } else { + return if (access is MemberAccess.MethodAccess && access.accessType == MethodAccessType.SPECIAL && access.ref.isConstructor()) { // constructors must always be declared by the type being constructed sequenceOf(type) + } else { + // fields and methods, except for constructors can be declared on any type in the hierarchy + allTypes } } diff --git a/tests/src/main/java/com/toasttab/expediter/test/caller/CallerNegative.java b/tests/src/main/java/com/toasttab/expediter/test/caller/CallerNegative.java index b47959e..f727fc4 100644 --- a/tests/src/main/java/com/toasttab/expediter/test/caller/CallerNegative.java +++ b/tests/src/main/java/com/toasttab/expediter/test/caller/CallerNegative.java @@ -21,6 +21,7 @@ import java.lang.invoke.VarHandle; import java.util.Arrays; import java.util.List; +import java.util.SortedSet; public class CallerNegative { private int x; @@ -45,6 +46,10 @@ String toStringOnInterfaceIsOk(List list) { return list.toString(); } + int inheritedInterfaceMethodIsOk(SortedSet set) { + return set.size(); + } + void privateAccessToNestedIsOk() { new Nested().f = 1; }