| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // SharedOptions=--supermixin | 4 // SharedOptions=--supermixin |
| 5 | 5 |
| 6 // Validate the following text from section 12 ("Mixins") of the spec: | 6 // Validate the following text from section 12 ("Mixins") of the spec: |
| 7 // | 7 // |
| 8 // "A mixin application of the form S with M; defines a class C ... | 8 // "A mixin application of the form S with M; defines a class C ... |
| 9 // ... C declares the same instance members as M ..." | 9 // ... C declares the same instance members as M ..." |
| 10 // | 10 // |
| 11 // This means that if M is itself a mixin application, then things | 11 // This means that if M is itself a mixin application, then things |
| 12 // mixed into M are accessible through C. But if M simply *extends* a | 12 // mixed into M are accessible through C. But if M simply *extends* a |
| 13 // mixin application (e.g. because M is declared as `class M extends X | 13 // mixin application (e.g. because M is declared as `class M extends X |
| 14 // with Y { ... }`) then things mixed into the mixin application that | 14 // with Y { ... }`) then things mixed into the mixin application that |
| 15 // M extends are not accessible through C. | 15 // M extends are not accessible through C. |
| 16 | 16 |
| 17 class A { a() => null; } | 17 class A { |
| 18 class B { b() => null; } | 18 a() => null; |
| 19 class C { c() => null; } | 19 } |
| 20 class D { d() => null; } | 20 |
| 21 class B { |
| 22 b() => null; |
| 23 } |
| 24 |
| 25 class C { |
| 26 c() => null; |
| 27 } |
| 28 |
| 29 class D { |
| 30 d() => null; |
| 31 } |
| 21 | 32 |
| 22 // Note: by a slight abuse of syntax, `class M1 = A with B, C;` effectively | 33 // Note: by a slight abuse of syntax, `class M1 = A with B, C;` effectively |
| 23 // means `class M1 = (A with B) with C;`, therefore M1 declares c(), but it | 34 // means `class M1 = (A with B) with C;`, therefore M1 declares c(), but it |
| 24 // merely inherits a() and b(). | 35 // merely inherits a() and b(). |
| 25 class M1 = A with B, C; // declares c() | 36 class M1 = A with B, C; // declares c() |
| 26 | 37 |
| 27 class M2 extends M1 { m2() => null; } | 38 class M2 extends M1 { |
| 28 class M3 extends A with B, C { m3() => null; } | 39 m2() => null; |
| 40 } |
| 41 |
| 42 class M3 extends A with B, C { |
| 43 m3() => null; |
| 44 } |
| 45 |
| 29 class T1 = D with M1; // declares c() | 46 class T1 = D with M1; // declares c() |
| 30 class T2 = D with M2; // declares m2() | 47 class T2 = D with M2; // declares m2() |
| 31 class T3 = D with M3; // declares m3() | 48 class T3 = D with M3; // declares m3() |
| 49 |
| 32 class T4 extends D with M1 {} // extends a class which declares c() | 50 class T4 extends D with M1 {} // extends a class which declares c() |
| 51 |
| 33 class T5 extends D with M2 {} // extends a class which declares m2() | 52 class T5 extends D with M2 {} // extends a class which declares m2() |
| 53 |
| 34 class T6 extends D with M3 {} // extends a class which declares m3() | 54 class T6 extends D with M3 {} // extends a class which declares m3() |
| 35 | 55 |
| 36 main() { | 56 main() { |
| 37 /// none: static type warning, ok | 57 /// none: static type warning, ok |
| 38 new T1().a(); // //# 01: static type warning, runtime error | 58 new T1().a(); // //# 01: static type warning, runtime error |
| 39 new T1().b(); // //# 02: static type warning, runtime error | 59 new T1().b(); // //# 02: static type warning, runtime error |
| 40 new T1().c(); // //# 03: static type warning, ok | 60 new T1().c(); // //# 03: static type warning, ok |
| 41 new T2().a(); // //# 04: static type warning, runtime error | 61 new T2().a(); // //# 04: static type warning, runtime error |
| 42 new T2().b(); // //# 05: static type warning, runtime error | 62 new T2().b(); // //# 05: static type warning, runtime error |
| 43 new T2().c(); // //# 06: static type warning, runtime error | 63 new T2().c(); // //# 06: static type warning, runtime error |
| 44 new T2().m2(); //# 07: static type warning, ok | 64 new T2().m2(); //# 07: static type warning, ok |
| 45 new T3().a(); // //# 08: static type warning, runtime error | 65 new T3().a(); // //# 08: static type warning, runtime error |
| 46 new T3().b(); // //# 09: static type warning, runtime error | 66 new T3().b(); // //# 09: static type warning, runtime error |
| 47 new T3().c(); // //# 10: static type warning, runtime error | 67 new T3().c(); // //# 10: static type warning, runtime error |
| 48 new T3().m3(); //# 11: static type warning, ok | 68 new T3().m3(); //# 11: static type warning, ok |
| 49 new T4().a(); // //# 12: static type warning, runtime error | 69 new T4().a(); // //# 12: static type warning, runtime error |
| 50 new T4().b(); // //# 13: static type warning, runtime error | 70 new T4().b(); // //# 13: static type warning, runtime error |
| 51 new T4().c(); // //# 14: static type warning, ok | 71 new T4().c(); // //# 14: static type warning, ok |
| 52 new T5().a(); // //# 15: static type warning, runtime error | 72 new T5().a(); // //# 15: static type warning, runtime error |
| 53 new T5().b(); // //# 16: static type warning, runtime error | 73 new T5().b(); // //# 16: static type warning, runtime error |
| 54 new T5().c(); // //# 17: static type warning, runtime error | 74 new T5().c(); // //# 17: static type warning, runtime error |
| 55 new T5().m2(); //# 18: static type warning, ok | 75 new T5().m2(); //# 18: static type warning, ok |
| 56 new T6().a(); // //# 19: static type warning, runtime error | 76 new T6().a(); // //# 19: static type warning, runtime error |
| 57 new T6().b(); // //# 20: static type warning, runtime error | 77 new T6().b(); // //# 20: static type warning, runtime error |
| 58 new T6().c(); // //# 21: static type warning, runtime error | 78 new T6().c(); // //# 21: static type warning, runtime error |
| 59 new T6().m3(); //# 22: static type warning, ok | 79 new T6().m3(); //# 22: static type warning, ok |
| 60 } | 80 } |
| OLD | NEW |