Entry points should always mark their declaring type live.
The bug has not been detected so far because static methods/JsConstructors always call enclosing type's $clinit method and so refers the declaring type. We should not rely on this and mark the declaring type of the entry point live.
@@ -56,6 +56,7 @@ final class RapidTypeAnalyser {
unfoldPolymorphicReference(member);
break;
case STATIC:
+ markTypeLive(member.getDeclaringType());
markMemberLive(member);
break;
case INSTANTIATION:
@@ -67,6 +68,10 @@ final class RapidTypeAnalyser {
}
}
+ private void onTypeReference(Type type) {
+ markTypeLive(type);
+ }
+
private void markMemberLive(Member member) {
if (!unusedMembers.remove(member)) {
// already live
@@ -98,7 +103,7 @@ final class RapidTypeAnalyser {
}
}
- private void onTypeReference(Type type) {
+ private void markTypeLive(Type type) {
if (!unusedTypes.remove(type)) {
// already live
return;
@@ -106,7 +111,7 @@ final class RapidTypeAnalyser {
// When a type is marked as live, we need to mark the super types as live too because their are
// referred to in the class declaration (as supertypes or encoded as implementing interfaces).
- type.getSuperTypes().forEach(this::onTypeReference);
+ type.getSuperTypes().forEach(this::markTypeLive);
}
private void instantiate(Type type) {
