OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class A { | 7 class A { |
8 const factory A() = B; | 8 const factory A() = B; |
9 } | 9 } |
10 | 10 |
11 class B implements A { | 11 class B implements A { |
12 const B(); | 12 const B(); |
13 | 13 |
14 operator ==(o) => true; // //# 00: compile-time error | 14 operator ==(o) => true; // //# 00: compile-time error |
15 } | 15 } |
16 | 16 |
17 @NoInline() @AssumeDynamic() | 17 @NoInline() |
| 18 @AssumeDynamic() |
18 confuse(x) => x; | 19 confuse(x) => x; |
19 | 20 |
20 main() { | 21 main() { |
21 // It is a compile-time error if the key type overrides operator ==. | 22 // It is a compile-time error if the key type overrides operator ==. |
22 var m = const { const A(): 42 }; | 23 var m = const {const A(): 42}; |
23 Expect.equals(42, m[confuse(const B())]); | 24 Expect.equals(42, m[confuse(const B())]); |
24 | 25 |
25 m = const { "foo": 99, const A(): 499 }; | 26 m = const {"foo": 99, const A(): 499}; |
26 Expect.equals(499, m[confuse(const B())]); | 27 Expect.equals(499, m[confuse(const B())]); |
27 } | 28 } |
OLD | NEW |