fix: Check for class type exactly instead of with contains (#310)

This commit is contained in:
oSumAtrIX 2024-09-18 14:36:15 +02:00 committed by GitHub
parent 525beda18e
commit 69f2f20fd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View file

@ -128,7 +128,7 @@ class Fingerprint internal constructor(
fun match(
context: BytecodePatchContext,
method: Method,
) = match(context, method, context.classByType(method.definingClass)!!.immutableClass)
) = match(context, method, context.classBy { method.definingClass == it.type }!!.immutableClass)
/**
* Match using a [Method].

View file

@ -104,6 +104,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
* @param type The type of the class.
* @return A proxy for the first class that matches the type.
*/
@Deprecated("Use classBy { type in it.type } instead.", ReplaceWith("classBy { type in it.type }"))
fun classByType(type: String) = classBy { type in it.type }
/**

View file

@ -179,7 +179,9 @@ internal object ClassMerger {
callback: MutableClass.() -> Unit,
) {
callback(targetClass)
this.classByType(targetClass.superclass ?: return)?.mutableClass?.let {
targetClass.superclass ?: return
this.classBy { targetClass.superclass == it.type }?.mutableClass?.let {
traverseClassHierarchy(it, callback)
}
}