diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2021-07-09 09:36:22 +0200 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2021-08-18 09:31:21 +0200 |
commit | 91859536db8cf4b59235c01474621f81641f9032 (patch) | |
tree | deda62d75a614231b7f19ef9cc9895bcd8205254 /src/utils/lombok/javac | |
parent | e050dafc9016519e79184e383eab9ffbd579bebd (diff) | |
download | lombok-91859536db8cf4b59235c01474621f81641f9032.tar.gz lombok-91859536db8cf4b59235c01474621f81641f9032.tar.bz2 lombok-91859536db8cf4b59235c01474621f81641f9032.zip |
[jdk17] Add support for default cases
Diffstat (limited to 'src/utils/lombok/javac')
-rw-r--r-- | src/utils/lombok/javac/JavacTreeMaker.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/utils/lombok/javac/JavacTreeMaker.java b/src/utils/lombok/javac/JavacTreeMaker.java index 30d71606..d369b4e4 100644 --- a/src/utils/lombok/javac/JavacTreeMaker.java +++ b/src/utils/lombok/javac/JavacTreeMaker.java @@ -607,7 +607,19 @@ public class JavacTreeMaker { public JCCase Case(JCExpression pat, List<JCStatement> stats) { if (tryResolve(Case11)) return invoke(Case11, pat, stats); - return invoke(Case12.Case12, Case12.CASE_KIND_STATEMENT, pat == null ? com.sun.tools.javac.util.List.nil() : com.sun.tools.javac.util.List.of(pat), stats, null); + List<JCTree> labels; + if (pat == null) { + labels = tryResolve(DefaultCaseLabel) ? List.of(DefaultCaseLabel()) : List.<JCTree>nil(); + } else { + labels = List.<JCTree>of(pat); + } + return invoke(Case12.Case12, Case12.CASE_KIND_STATEMENT, labels, stats, null); + } + + //javac versions: 17 + private static final MethodId<JCTree> DefaultCaseLabel = MethodId("DefaultCaseLabel", JCTree.class); + public JCTree DefaultCaseLabel() { + return invoke(DefaultCaseLabel); } //javac versions: 6-8 |