Skip to content

Commit

Permalink
Fix crash when warner stack is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mcimadamore committed Aug 22, 2024
1 parent fc76d38 commit 21af275
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ public boolean isSubtype(Type t, Type s, boolean capture, Warner warner) {

public boolean isSubtype(Type t, Type s, boolean capture) {
if (t.equalsIgnoreMetadata(s)) {
if (enableNullRestrictedTypes && hasNarrowerNullability(s, t)) {
if (enableNullRestrictedTypes && warnStack.nonEmpty() && hasNarrowerNullability(s, t)) {
warnStack.head.warn(LintCategory.NULL);
}
return true;
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public Boolean visitClassType(ClassType t, Type s) {
&& (!s.isParameterized() || containsTypeRecursive(s, sup))
&& isSubtypeNoCapture(sup.getEnclosingType(),
s.getEnclosingType());
if (result && enableNullRestrictedTypes && hasNarrowerNullability(s, t)) {
if (result && enableNullRestrictedTypes && warnStack.nonEmpty() && hasNarrowerNullability(s, t)) {
warnStack.head.warn(LintCategory.NULL);
}
return result;
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public Boolean visitClassType(ClassType t, Type s) {
boolean equal = t.tsym == s.tsym
&& visit(t.getEnclosingType(), s.getEnclosingType())
&& containsTypeEquivalent(t.getTypeArguments(), s.getTypeArguments());
if (equal && enableNullRestrictedTypes && !hasSameNullability(s, t)) {
if (equal && enableNullRestrictedTypes && warnStack.nonEmpty() && !hasSameNullability(s, t)) {
warnStack.head.warn(LintCategory.NULL);
}
return equal;
Expand Down

0 comments on commit 21af275

Please sign in to comment.