Withdrawn: 8269738: AssertionError when combining pattern matching and function closure

Guoxiong Li gli at openjdk.java.net
Thu Jul 8 04:34:52 UTC 2021


On Sat, 3 Jul 2021 19:27:34 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> Hi all,
> 
> The method `TransPatterns.BasicBindingContext::bindingDeclared` uses `varSymbol.owner` to construct a new `VarSymbol`. 
> 
> 
>      res = new VarSymbol(varSymbol.flags(), varSymbol.name, varSymbol.type, varSymbol.owner);
> 
> 
> But the `varSymbol.owner` may be also a `VarSymbol` when it is at the `init` clause of the static variables or instance variables.
> You can see the following code. The `owner` of the `Interger i` is `staticNum1` or `instanceNum1` which is `VarSymbol`.
> 
> 
>     static Number num1 = 1;
>     static Number staticNum1 = (num1 instanceof Integer i) ? ((Supplier<Integer>) () -> i).get() : null;
>     Number instanceNum1 = (num1 instanceof Integer i) ? ((Supplier<Integer>) () -> i).get() : null;
> 
> 
> Then, the class `LambdaToMethod` can't capture the expected variables `Integer i` and the following phases such as `Gen` may fail or throw exceptions.
> 
> This patch uses the `currentMethodSym` which means a class or instance field initializer to replace `varSymbol.owner` and adds the corresponding test.
> 
> ---
> 
> And I have a problem:
> 
>> The `owner` of the `Interger i` is `staticNum1` or `instanceNum1` which is `VarSymbol`.
> 
> The statement above means the `env.info.scope.owner` in the method `Attr::visitBindingPattern` is a `VarSymbol`. Is it a expected result? Or the original `env.info.scope.owner` should be modified to a class or instance field initializer which the following phases need.
> 
> 
>     // Attr.java
>     public void visitBindingPattern(JCBindingPattern tree) {
>         ......
>         BindingSymbol v = new BindingSymbol(tree.var.mods.flags, tree.var.name, tree.var.vartype.type, env.info.scope.owner);
>         ......
>     }
> 
> 
> ---
> 
> 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/4678


More information about the compiler-dev mailing list