Skip to content

Commit

Permalink
Fixed NPE in TypeManager (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto authored Sep 7, 2021
1 parent 080a784 commit f768593
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ public enum Language {
// as Values
private Set<Type> firstOrderTypes = Collections.synchronizedSet(new HashSet<>());
private Set<Type> secondOrderTypes = Collections.synchronizedSet(new HashSet<>());

/**
* The language frontend that is currently active. This can be null, e.g. if we are executed in tests.
*/
@org.jetbrains.annotations.Nullable
private LanguageFrontend frontend;

private boolean noFrontendWarningIssued = false;

public static void reset() {
Expand Down Expand Up @@ -515,7 +521,7 @@ public Language getLanguage() {
return Language.TYPESCRIPT;
}

log.error("Unknown language (frontend: {})", frontend.getClass().getSimpleName());
log.error("Unknown language (frontend: {})", frontend != null ? frontend.getClass().getSimpleName() : null);
return Language.UNKNOWN;
}

Expand Down Expand Up @@ -677,6 +683,15 @@ public void handleSingleAlias(String rawCode, Type target, String aliasString) {
}

TypedefDeclaration typedef = NodeBuilder.newTypedefDeclaration(currTarget, alias, rawCode);

if (frontend == null) {
if (!noFrontendWarningIssued) {
log.warn("No frontend available. Be aware that typedef resolving cannot currently be done");
noFrontendWarningIssued = true;
}
return;
}

frontend.getScopeManager().addTypedef(typedef);
}

Expand All @@ -688,6 +703,7 @@ public Type resolvePossibleTypedef(Type alias) {
}
return alias;
}

Type toCheck = alias.getRoot();

Type finalToCheck = toCheck;
Expand Down

0 comments on commit f768593

Please sign in to comment.