Skip to content

Commit

Permalink
fix method desc with propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Sep 22, 2024
1 parent c978761 commit 0938bd3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ abstract class InheritanceTree(val tree: AbstractMappingTree, val fns: Namespace
overwriteParentMethodNames(md, names.filterKeys { it in needsOverwrite })
}
clsNode?.visitMethod(
mapOf(fns to (md.name to md.descriptor)) +
names.mapValues { it.value to null }
names.mapValues { it.value to null } +
mapOf(fns to (md.name to md.descriptor))
)?.visitEnd()
names[fns] = md.name
md to names
Expand Down Expand Up @@ -142,8 +142,8 @@ abstract class InheritanceTree(val tree: AbstractMappingTree, val fns: Namespace
if (md in methodData) {
methodData[md]!!.putAll(names)
clsNode?.visitMethod(mapOf(
fns to (md.name to md.descriptor),
*names.mapValues { it.value to null }.entries.map { it.key to it.value }.toTypedArray()
*names.mapValues { it.value to null }.entries.map { it.key to it.value }.toTypedArray(),
fns to (md.name to md.descriptor)
))?.visitEnd()
overwriteParentMethodNames(md, names)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,23 @@ abstract class FieldMethodResolvable<T: FieldMethodResolvable<T, U>, U: MemberVi
return null
}

// warn if a method name is getting implicitly overridden
if (notMatched) {
LOGGER.warn {
"""
Joining different names, second will take priority
$element
$this
""".trimIndent()
}
}

return if (element.hasDescriptor()) {
if (descs.isNotEmpty()) {
val descNs = descs.keys.first()
if (element.getDescriptor(descNs) == descs[descNs]) {
// same descriptor, merge

// warn if a method name is getting implicitly overridden
if (notMatched) {
LOGGER.warn {
"""
Joining different names, second will take priority
$element
$this
""".trimIndent()
}
}

element.setNames(names)
element.setDescriptors(descs)
doMerge(element)
Expand All @@ -77,6 +78,18 @@ abstract class FieldMethodResolvable<T: FieldMethodResolvable<T, U>, U: MemberVi
}
} else {
// merge, but also create new unmerged one

// warn if a method name is getting implicitly overridden
if (notMatched) {
LOGGER.warn {
"""
Joining different names, second will take priority
$element
$this
""".trimIndent()
}
}

val new = create(parent as ClassNode)
new.setNames(names)
element.setNames(names)
Expand All @@ -87,6 +100,18 @@ abstract class FieldMethodResolvable<T: FieldMethodResolvable<T, U>, U: MemberVi
} else {
if (descs.isNotEmpty()) {
// merge, but also create a new one with descs

// warn if a method name is getting implicitly overridden
if (notMatched) {
LOGGER.warn {
"""
Joining different names, second will take priority
$element
$this
""".trimIndent()
}
}

val new = create(parent as ClassNode)
new.setNames(element.names)
new.setNames(names)
Expand All @@ -96,6 +121,18 @@ abstract class FieldMethodResolvable<T: FieldMethodResolvable<T, U>, U: MemberVi
new
} else {
// merge

// warn if a method name is getting implicitly overridden
if (notMatched) {
LOGGER.warn {
"""
Joining different names, second will take priority
$element
$this
""".trimIndent()
}
}

element.setNames(names)
doMerge(element)
element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.wagyourtail.unimined.mapping.tree.node._class.member

import io.github.oshai.kotlinlogging.KotlinLogging
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.umf.UMFWriter
import xyz.wagyourtail.unimined.mapping.jvms.ext.FieldOrMethodDescriptor
Expand Down

0 comments on commit 0938bd3

Please sign in to comment.