Stephan Herhut | 3600c13 | 2017-11-07 12:05:30 +0100 | [diff] [blame] | 1 | // 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. |
| 4 | package shaking; |
| 5 | |
| 6 | public class SubClassOne implements InterfaceWithDefault, OtherInterfaceWithDefault { |
| 7 | |
| 8 | @Override |
| 9 | public void foo() { |
| 10 | System.out.println("Method foo from SubClassOne"); |
| 11 | makeSubClassTwoLive().foo(); |
| 12 | asOtherInterface().bar(); |
| 13 | } |
| 14 | |
| 15 | private OtherInterface asOtherInterface() { |
| 16 | return new SubClassTwo(); |
| 17 | } |
| 18 | |
| 19 | @Override |
| 20 | public void bar() { |
| 21 | System.out.println("Method bar from SubClassOne"); |
| 22 | } |
| 23 | |
| 24 | private InterfaceWithDefault makeSubClassTwoLive() { |
| 25 | // Once we see this method, SubClassTwo will be live. This should also make the default method |
| 26 | // in the interface live, as SubClassTwo does not override it. |
| 27 | return new SubClassTwo(); |
| 28 | } |
| 29 | } |