Skip to content

Commit d65d8bc

Browse files
authored
Fix MappingSourceNsSwitch not dropping entries with missing destination names (#133)
1 parent 3c390d8 commit d65d8bc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/net/fabricmc/tinyremapper/TinyUtils.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ private static MappingVisitor createAdapter(String fromNs, String toNs, MappingA
9797
new MappingDstNsReorder(
9898
new FlatAsRegularMappingVisitor(new MappingAdapter(out)),
9999
toNs),
100-
fromNs);
100+
fromNs,
101+
true);
101102
}
102103

103104
private static final class MappingAdapter implements FlatMappingVisitor {
@@ -108,23 +109,23 @@ private static final class MappingAdapter implements FlatMappingVisitor {
108109
@Override
109110
public boolean visitClass(String srcName, String[] dstNames) throws IOException {
110111
String dstName = dstNames[0];
111-
if (!bothNullOrEqual(srcName, dstName)) next.acceptClass(srcName, dstName);
112+
if (!anyNullOrEqual(srcName, dstName)) next.acceptClass(srcName, dstName);
112113
return true;
113114
}
114115

115116
@Override
116117
public boolean visitField(String srcClsName, String srcName, String srcDesc,
117118
String[] dstClsNames, String[] dstNames, String[] dstDescs) throws IOException {
118119
String dstName = dstNames[0];
119-
if (!bothNullOrEqual(srcName, dstName)) next.acceptField(new Member(srcClsName, srcName, srcDesc), dstName);
120+
if (!anyNullOrEqual(srcName, dstName)) next.acceptField(new Member(srcClsName, srcName, srcDesc), dstName);
120121
return false;
121122
}
122123

123124
@Override
124125
public boolean visitMethod(String srcClsName, String srcName, String srcDesc,
125126
String[] dstClsNames, String[] dstNames, String[] dstDescs) throws IOException {
126127
String dstName = dstNames[0];
127-
if (!bothNullOrEqual(srcName, dstName)) next.acceptMethod(new Member(srcClsName, srcName, srcDesc), dstName);
128+
if (!anyNullOrEqual(srcName, dstName)) next.acceptMethod(new Member(srcClsName, srcName, srcDesc), dstName);
128129
return true;
129130
}
130131

@@ -164,7 +165,7 @@ private static boolean firstNullOrEqual(Object o1, Object o2) {
164165
return o1 == null || o1.equals(o2);
165166
}
166167

167-
private static boolean bothNullOrEqual(Object o1, Object o2) {
168+
private static boolean anyNullOrEqual(Object o1, Object o2) {
168169
return o2 == null || firstNullOrEqual(o1, o2);
169170
}
170171
}

0 commit comments

Comments
 (0)