Skip to content

Commit

Permalink
fix stub overriding names
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 10, 2024
1 parent fc5c91b commit acf38c3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ abstract class FieldMethodResolvable<T: FieldMethodResolvable<T, U>, U: MemberVi
for (name in names.keys) {
val nameVal = names[name]!!
val elementNameVal = element.names[name] ?: continue
if (elementNameVal != nameVal) {
// dont merge
return null
if (elementNameVal == nameVal) {
matched = true
}
matched = true
}

if (!matched) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,38 @@ c net/minecraft/class_310 net/minecraft/client/MinecraftClient net/minecraft/Min
""".trimIndent()
assertEquals(testOuput, output.trimEnd())
}

@Test
fun testOverrideName() = runTest {
val inp = """
umf 1 0
intermediary named
c net/minecraft/class_310 net/minecraft/client/MinecraftClient
* "example comment" named
f field_1724 _
m method_1507;()V testMethod;()V
p _ 0 _ this
v 1 _ _ lv1
m method_1507;()V nameOverride;()V
""".trimIndent().trimEnd()

val mappings = Buffer().use { input ->
input.writeUtf8(inp)
UMFReader.read(input)
}
val output = Buffer().use { output ->
mappings.accept(UMFWriter.write(output, false))
output.readUtf8()
}
assertEquals("""
umf 1 0
intermediary named
c net/minecraft/class_310 net/minecraft/client/MinecraftClient
* "example comment" named
f field_1724 _
m method_1507;()V nameOverride;()V
p _ 0 _ this
v 1 _ _ lv1
""".trimIndent(), output.trimEnd())
}
}

0 comments on commit acf38c3

Please sign in to comment.