Skip to content

Commit

Permalink
Fix ASTConverter_RecordPattern_Test.testCaseDefaultExpressionPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Aug 14, 2024
1 parent 2fa6e14 commit 5bfbcd5
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
import com.sun.tools.javac.tree.JCTree.JCParens;
import com.sun.tools.javac.tree.JCTree.JCPattern;
import com.sun.tools.javac.tree.JCTree.JCPatternCaseLabel;
import com.sun.tools.javac.tree.JCTree.JCConstantCaseLabel;
import com.sun.tools.javac.tree.JCTree.JCDefaultCaseLabel;
import com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree;
import com.sun.tools.javac.tree.JCTree.JCProvides;
import com.sun.tools.javac.tree.JCTree.JCRecordPattern;
Expand Down Expand Up @@ -2427,6 +2429,25 @@ private Statement convertSwitchCase(JCCase jcCase) {

} else {
// Override length to just be `case blah:`
for (JCCaseLabel jcLabel : jcCase.getLabels()) {
switch (jcLabel) {
case JCConstantCaseLabel constantLabel: {
if (constantLabel.expr.toString().equals("null")) {
res.expressions().add(this.ast.newNullLiteral());
}
break;
}
case JCDefaultCaseLabel defaultCase: {
if (jcCase.getLabels().size() != 1) {
res.expressions().add(this.ast.newCaseDefaultExpression());
}
break;
}
default: {
break;
}
}
}
int start1 = res.getStartPosition();
int colon = this.rawText.indexOf(":", start1);
if( colon != -1 ) {
Expand Down

0 comments on commit 5bfbcd5

Please sign in to comment.