test/langtools/tools/javac/lvti/SelfRefTest.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47268 48ec75306997
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com

/*
 * @test /nodynamiccopyright/
 * @bug 8177466
 * @summary Add compiler support for local variable type-inference
 * @compile/fail/ref=SelfRefTest.out -XDrawDiagnostics SelfRefTest.java
 */

import java.util.function.Function;

class SelfRefTest {

        int q() { return 42; }
    int m(int t) { return t; }

    void test(boolean cond) {
       var x = cond ? x : x; //error - self reference
       var y = (Function<Integer, Integer>)(Integer y) -> y; //error - bad shadowing
       var z = (Runnable)() -> { int z2 = m(z); }; //error - self reference
       var w = new Object() { int w = 42; void test() { int w2 = w; } }; //ok
       int u = u; //ok
       int q = q(); //ok
    }
}