clementbera | 7288597 | 2019-05-21 12:30:02 +0200 | [diff] [blame] | 1 | // Copyright (c) 2019, 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 | |
clementbera | be19d30 | 2019-05-23 17:23:21 +0200 | [diff] [blame] | 5 | package nesthostexample; |
clementbera | 948e418 | 2019-05-14 12:25:26 +0200 | [diff] [blame] | 6 | |
| 7 | public class BasicNestHostClassMerging { |
| 8 | |
| 9 | private String field = "Outer"; |
| 10 | |
| 11 | public static class MiddleOuter extends BasicNestHostClassMerging { |
| 12 | |
| 13 | private String field = "Middle"; |
| 14 | |
| 15 | public static void main(String[] args) { |
| 16 | System.out.println(new InnerMost().getFields()); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | public static class MiddleInner extends MiddleOuter { |
| 21 | private String field = "Inner"; |
| 22 | } |
| 23 | |
| 24 | public static class InnerMost extends MiddleInner { |
| 25 | |
clementbera | d5bd4f3 | 2019-05-21 12:22:06 +0200 | [diff] [blame] | 26 | @NeverInline |
clementbera | 948e418 | 2019-05-14 12:25:26 +0200 | [diff] [blame] | 27 | public String getFields() { |
| 28 | return ((BasicNestHostClassMerging) this).field |
| 29 | + ((MiddleOuter) this).field |
| 30 | + ((MiddleInner) this).field; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | public static void main(String[] args) { |
| 35 | System.out.println(new InnerMost().getFields()); |
| 36 | } |
| 37 | } |