Christoffer Quist Adamsen | 8c92122 | 2018-07-11 13:33:56 +0200 | [diff] [blame] | 1 | // Copyright (c) 2018, 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. |
| 4 | |
| 5 | package classmerging; |
| 6 | |
| 7 | public class NestedDefaultInterfaceMethodsTest { |
| 8 | |
| 9 | public static void main(String[] args) { |
Christoffer Quist Adamsen | bfdbe60 | 2019-10-18 12:03:31 +0200 | [diff] [blame] | 10 | C obj = new C(); |
| 11 | obj.m(); |
| 12 | |
| 13 | // Ensure that the instantiations are not dead code eliminated. |
| 14 | escape(obj); |
| 15 | } |
| 16 | |
| 17 | @NeverInline |
| 18 | static void escape(Object o) { |
| 19 | if (System.currentTimeMillis() < 0) { |
| 20 | System.out.println(o); |
| 21 | } |
Christoffer Quist Adamsen | 8c92122 | 2018-07-11 13:33:56 +0200 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | public interface A { |
| 25 | |
| 26 | default void m() { |
| 27 | System.out.println("In A.m()"); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public interface B extends A { |
| 32 | |
| 33 | @Override |
| 34 | default void m() { |
| 35 | System.out.println("In B.m()"); |
| 36 | A.super.m(); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public static class C implements B { |
| 41 | |
| 42 | @Override |
| 43 | public void m() { |
| 44 | System.out.println("In C.m()"); |
| 45 | B.super.m(); |
| 46 | } |
| 47 | } |
| 48 | } |