Skip to content

Commit aeddb85

Browse files
committed
Reflecting review comments.
1 parent 3fc2502 commit aeddb85

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

make/CompileInterimLangtools.gmk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
4949
$(INTERIM_LANGTOOLS_MODULES))
5050

5151
$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
52-
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \
52+
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \
53+
$(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \
5354
DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/, \
5455
))
5556

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public void visitSwitchExpression(JCSwitchExpression tree) {
709709
constants = new HashSet<>();
710710
constants.addAll(((ClassSymbol) selectorSym).permitted);
711711
}
712-
boolean coversInput = false;
712+
boolean coversInput = tree.hasTotalPattern;
713713
Liveness prevAlive = alive;
714714
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
715715
alive = Liveness.ALIVE;
@@ -750,8 +750,8 @@ public void visitSwitchExpression(JCSwitchExpression tree) {
750750
}
751751
c.completesNormally = alive != Liveness.DEAD;
752752
}
753-
if ((constants == null || !constants.isEmpty()) && !tree.hasTotalPattern &&
754-
!coversInput && !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) {
753+
if ((constants == null || !constants.isEmpty()) && !coversInput &&
754+
!TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) {
755755
log.error(tree, Errors.NotExhaustive);
756756
}
757757
alive = prevAlive;

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,26 +287,28 @@ private void handleSwitch(JCTree tree,
287287
//int $idx = 0;
288288
//$RESTART: switch (invokeDynamic typeSwitch($constant, typeof($pattern1), typeof($pattern2), typeof($pattern3))($obj, $idx)) {
289289
// case 0:
290-
// if (!(<desugared $pattern1)) { $idx = 1; continue $RESTART; }
290+
// if (!(<desugared $pattern1>)) { $idx = 1; continue $RESTART; }
291291
// $stats$
292292
// case 1:
293-
// if (!(<desugared $pattern1)) { $idx = 2; continue $RESTART; }
293+
// if (!(<desugared $pattern1>)) { $idx = 2; continue $RESTART; }
294294
// $stats$
295295
// case 2, -1:
296-
// if (!(<desugared $pattern1)) { $idx = 3; continue $RESTART; }
296+
// if (!(<desugared $pattern1>)) { $idx = 3; continue $RESTART; }
297297
// $stats$
298298
// case 3:
299-
// if (!(<desugared $pattern1)) { $idx = 4; continue $RESTART; }
299+
// if (!(<desugared $pattern1>)) { $idx = 4; continue $RESTART; }
300300
// $stats$
301301
//}
302302
//notes:
303303
//-pattern desugaring performs assignment to the binding variables
304304
//-the selector is evaluated only once and stored in a temporary variable
305305
//-typeSwitch bootstrap method can restart matching at specified index. The bootstrap will
306306
// categorize the input, and return the case index whose type or constant matches the input.
307-
// The bootstrap does not evaluate guards, which are injected at the begining of the case's
307+
// The bootstrap does not evaluate guards, which are injected at the beginning of the case's
308308
// statement list, and if the guard fails, the switch is "continued" and matching is
309309
// restarted from the next index.
310+
//-case null is always desugared to case -1, as the typeSwitch bootstrap method will
311+
// return -1 when the input is null
310312
//
311313
//a special case for switches over enums with pattern case
312314
//only a single (type) pattern case is valid, which is equivalent

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,6 @@ public boolean isPattern() {
22382238
public static class JCBindingPattern extends JCPattern
22392239
implements BindingPatternTree {
22402240
public JCVariableDecl var;
2241-
// public boolean nullable;
22422241

22432242
protected JCBindingPattern(JCVariableDecl var) {
22442243
this.var = var;

0 commit comments

Comments
 (0)