[lvti] Possible compiler bug

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sun Jun 25 20:48:59 UTC 2017


Thanks - I'll look into this - seems like the rule for rejecting 
self-references is bleeding into wrong places.

I'll also correct the error messages - thanks for noticing

Maurizio


On 25/06/17 11:36, Tagir Valeev wrote:
> Hello! The following code is not compilable in [lvti] branch, but it should
> be, to my opinion:
>
> public class LvtiBug {
>    int x() { return 0; }
>
>    void test() {
>      var x = x();
>    }
> }
>
> $ javac LvtiBug.java
> LvtiBug.java:5: error: cannot infer type for local variable x
>      var x = x();
>          ^
>    (cannot use 'val' on self-referencing variable)
> 1 error
>
> Also, I believe, the message should have 'var', not 'val':
>
> diff -r a7aba322684f
> src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> ---
> a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> Fri
> Jun 23 11:47:57 2017 +0100
> +++
> b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> Sun
> Jun 25 17:34:47 2017 +0700
> @@ -1205,7 +1205,7 @@
>       variable initializer is ''null''
>
>   compiler.misc.local.missing.init=\
> -    cannot use ''val'' on variable without initializer
> +    cannot use ''var'' on variable without initializer
>
>   compiler.misc.local.lambda.missing.target=\
>       lambda expression needs an explicit target-type
> @@ -1217,7 +1217,7 @@
>       array initializer needs an explicit target-type
>
>   compiler.misc.local.self.ref=\
> -    cannot use ''val'' on self-referencing variable
> +    cannot use ''var'' on self-referencing variable
>
>   compiler.misc.local.non.denotable=\
>       inferred type is non denotable
>
> With best regards,
> Tagir Valeev



More information about the amber-dev mailing list