blob: a133a7bad2db90dc23b1512243c2fcca1846ee80 [file] [log] [blame]
Denis Vnukovfac11c02017-12-08 08:32:00 -08001// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package privateinterfacemethods;
5
6public class PrivateInterfaceMethods {
7
8 public static void main(String[] args) {
9 System.out.println("1: " + I.DEFAULT.dFoo());
10 System.out.println("2: " + I.DEFAULT.lFoo());
11 System.out.println("3: " + I.xFoo());
12 System.out.println("4: " + new C().dFoo());
13 }
14}
15
16class C implements I {
17
18 public String dFoo() {
19 return "c>" + I.super.dFoo();
20 }
21}
22
23interface IB {
24
25 String dFoo();
26}
27
28interface I {
29
30 I DEFAULT = new I() {{
31 System.out.println("0: " + sFoo(false, this));
32 }};
33
34 static String xFoo() {
35 return "x>" + sFoo(true, null);
36 }
37
38 private static String sFoo(boolean simple, I it) {
39 return simple ? "s"
40 : ("s>" + it.iFoo(true) + ">" + new I() {
41 public String dFoo() {
42 return "a";
43 }
44 }.dFoo());
45 }
46
47 private String iFoo(boolean skip) {
48 return skip ? "i" : ("i>" + sFoo(false, this));
49 }
50
51 default String dFoo() {
52 return "d>" + iFoo(false);
53 }
54
55 default String lFoo() {
56 IB ib = () -> "l>" + iFoo(false);
57 return ib.dFoo();
58 }
59}