@@ -38,6 +38,10 @@ abstract class MethodSignatureRef(
3838 private val alwaysTrue: (JcTypedMethod ) -> Boolean = { true }
3939 }
4040
41+ private fun predicate (additionalFilter : (JcTypedMethod ) -> Boolean = alwaysTrue): (JcTypedMethod ) -> Boolean = {
42+ it.name == name && additionalFilter(it) && it.method.description == description
43+ }
44+
4145 protected val description: String = buildString {
4246 append(" (" )
4347 argTypes.forEach {
@@ -48,17 +52,16 @@ abstract class MethodSignatureRef(
4852 }
4953
5054 private fun List<JcTypedMethod>.findMethod (filter : (JcTypedMethod ) -> Boolean = alwaysTrue): JcTypedMethod ? {
51- return firstOrNull { it.name == name && filter(it) && it.method.description == description }
55+ return firstOrNull(predicate(filter))
5256 }
5357
5458 protected fun JcClassType.findTypedMethod (filter : (JcTypedMethod ) -> Boolean = alwaysTrue): JcTypedMethod {
55- return findMethodOrNull(filter) ? : throw IllegalStateException (this .methodNotFoundMessage)
59+ return findMethodOrNull(predicate( filter) ) ? : throw IllegalStateException (this .methodNotFoundMessage)
5660 }
5761
5862 protected fun JcClassType.findTypedMethodOrNull (filter : (JcTypedMethod ) -> Boolean = alwaysTrue): JcTypedMethod ? {
59- var methodOrNull = findMethodOrNull {
60- it.name == name && filter(it) && it.method.description == description
61- }
63+ var methodOrNull = findMethodOrNull(predicate(filter))
64+
6265 if (methodOrNull == null && jcClass.packageName == " java.lang.invoke" ) {
6366 methodOrNull = findMethodOrNull {
6467 val method = it.method
@@ -194,11 +197,11 @@ class VirtualMethodRefImpl(
194197 }
195198
196199 override val method: JcTypedMethod by softLazy {
197- actualType.findTypedMethodOrNull { ! it.isPrivate } ? : declaredMethod
200+ actualType.findTypedMethodOrNull() ? : declaredMethod
198201 }
199202
200203 override val declaredMethod: JcTypedMethod by softLazy {
201- type.findTypedMethod { ! it.isPrivate }
204+ type.findTypedMethod()
202205 }
203206}
204207
0 commit comments