| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Fletch 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.md file. | |
| 4 | |
| 5 library myapi_impl; | |
| 6 | |
| 7 const myapi = const Api('MyApi'); | |
| 8 | |
| 9 int calls = 0; | |
| 10 @myapi MyObject foo() { | |
| 11 return (calls++ & 1 == 0) ? new Bar() : new Baz(); | |
| 12 } | |
| 13 | |
| 14 abstract class MyObject { | |
| 15 @myapi void funk(MyObject o); | |
| 16 } | |
| 17 | |
| 18 class Bar implements MyObject { | |
| 19 void funk(MyObject o) { | |
| 20 print("Bar!"); | |
| 21 if (o != null) o.funk(null); | |
| 22 } | |
| 23 } | |
| 24 | |
| 25 class Baz implements MyObject { | |
| 26 void funk(MyObject o) { | |
| 27 print("Baz!"); | |
| 28 if (o != null) o.funk(null); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 | |
| 33 // --------------------------------------------------------------- | |
| 34 | |
| 35 class Api { | |
| 36 final String name; | |
| 37 const Api(this.name); | |
| 38 } | |
| OLD | NEW |