QuiltMC / enigma

A deobfuscation/remapping tool for Java bytecode, fork of cuchaz's Enigma.
GNU Lesser General Public License v3.0
59 stars 31 forks source link

Proposal propagation issues #228

Open supersaiyansubtlety opened 2 months ago

supersaiyansubtlety commented 2 months ago

Working on net/minecraft/village/TradeOffers$EnchantBookFactory on https://github.com/QuiltMC/quilt-mappings/commit/3f6043b663243099a0ae112421f01f52342c2750

Proposed param names don't always propagate through constructors, and you can end up with a "ghost" proposal from a previous name that was reset.

I think these issues are just "visual" issues in the editor.

0. Start state ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey f_fykexdki; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey arg) { this(experience, 0, Integer.MAX_VALUE, arg); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey arg) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.f_fykexdki = arg; } //... } ```
1. Name `f_fykexdki` -> `enchantmentPool` (no propagation) change propagates to the second constructor, but not the first ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey enchantmentPool; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey arg) { this(experience, 0, Integer.MAX_VALUE, arg); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey enchantmentPool) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.enchantmentPool = enchantmentPool; } //... } ```
2. Give first constructor param a temp name so it can be reset to obfuscated ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey enchantmentPool; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey TEMP) { this(experience, 0, Integer.MAX_VALUE, TEMP); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey enchantmentPool) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.enchantmentPool = enchantmentPool; } //... } ```
3. Reset `TEMP` to obfuscated it ends up with the correct name ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey enchantmentPool; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey enchantmentPool) { this(experience, 0, Integer.MAX_VALUE, enchantmentPool); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey enchantmentPool) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.enchantmentPool = enchantmentPool; } //... } ```
4. Reset `enchantmentPool` field to obfuscated (no propagation) change propagates to the second constructor, but not the first, as in 2. ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey f_fykexdki; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey enchantmentPool) { this(experience, 0, Integer.MAX_VALUE, enchantmentPool); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey arg) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.f_fykexdki = arg; } //... } ```
5. Repeat 2. ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey f_fykexdki; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey TEMP) { this(experience, 0, Integer.MAX_VALUE, TEMP); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey arg) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.f_fykexdki = arg; } //... } ```
6. Repeat 3. ("ghost" proposal) `TEMP` gets reset to `enchantmentPool`, despite that name appearing nowhere else. Restarting the editor makes it go back to `arg` as expected. ```java static class EnchantBookFactory implements TradeOffers.Factory { private final int experience; private final TagKey f_fykexdki; private final int minLevel; private final int maxLevel; public EnchantBookFactory(int experience, TagKey enchantmentPool) { this(experience, 0, Integer.MAX_VALUE, enchantmentPool); } public EnchantBookFactory(int experience, int minLevel, int maxLevel, TagKey arg) { this.minLevel = minLevel; this.maxLevel = maxLevel; this.experience = experience; this.f_fykexdki = arg; } //... } ```