Withdrawn: 8269113: Javac throws when compiling switch (null)
duke
duke at openjdk.java.net
Wed Sep 1 22:56:31 UTC 2021
On Sun, 4 Jul 2021 18:13:26 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> When we use `switch(null)` in the source code, the type of the selector is `BottomType`.
> So the statement `Type seltype = selector.type;` of the method `TransPatterns::handleSwitch` will get a `BottomType`.
> Then compiler mistakenly uses this `BottomType` to construct a new `VarSymbol`.
>
>
> VarSymbol temp = new VarSymbol(Flags.SYNTHETIC,
> names.fromString("selector" + tree.pos + target.syntheticNameChar() + "temp"),
> seltype, // <--------here is a BottomType
> currentMethodSym);
>
>
> At last, when the compiler uses the new `VarSymbol temp` to construct a new `JCVariableDecl`(the code shown as below), it crashes at the method `TreeMaker::Type` because the method `TreeMaker::Type` can't handle the type `BottomType`.
>
>
> statements.append(make.at(tree.pos).VarDef(temp, !hasNullCase ? attr.makeNullCheck(selector)
> : selector));
>
>
> This patch changes the type from `BottomType` to `syms.objectType` and adds the corresponding test.
> Thanks for taking the time to review.
>
> Best Regards,
> -- Guoxiong
This pull request has been closed without being integrated.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4679
More information about the compiler-dev
mailing list