Open mayakwd opened 5 years ago
Fixing this NPE is easy, if we just test for null, but that's not the underlying problem, I think. Do you have any example code that triggered the error, so I can figure out why there is no underlying type in the model?
The model is made from a HaxeClass, so I don't know why the type model wouldn't be able to reference it:
@NotNull
private static HaxeClassResolveResult fullyResolveTypedef(@Nullable HaxeClass typedef, @Nullable HaxeGenericSpecialization specialization) {
if (null == typedef) return HaxeClassResolveResult.EMPTY;
HashSet<String> recursionGuard = new HashSet<>(); // Track which typedefs we've already resolved so we don't end up in an infinite loop.
HaxeClassResolveResult result = HaxeClassResolveResult.EMPTY;
HaxeClassModel model = typedef.getModel();
while (null != model && model.isTypedef() && !recursionGuard.contains(model.getName())) {
recursionGuard.add(model.getName());
final HaxeTypeOrAnonymous toa = model.getUnderlyingType(); // <<<<----- NPE occurs here.
final HaxeType type = toa.getType();
if (null == type) {
// Anonymous structure
result = HaxeClassResolveResult.create(toa.getAnonymousType(), specialization);
break;
}
// If the reference is to a type parameter, resolve that instead.
HaxeClassResolveResult nakedResult = specialization.get(type, type.getReferenceExpression().getIdentifier().getText());
if (null == nakedResult) {
nakedResult = type.getReferenceExpression().resolveHaxeClass();
}
result = HaxeClassResolveResult.create(nakedResult.getHaxeClass(), specialization);
model = null != result.getHaxeClass() ? result.getHaxeClass().getModel() : null;
}
return result;
}
[EDIT: Add the rest of the function for context.]
I'll try to extract pure sample to reproduce.