OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:kernel/ast.dart'; | 5 import 'package:kernel/ast.dart'; |
6 import 'package:kernel/class_hierarchy.dart'; | 6 import 'package:kernel/class_hierarchy.dart'; |
7 import 'package:kernel/core_types.dart'; | 7 import 'package:kernel/core_types.dart'; |
8 import 'package:kernel/src/incremental_class_hierarchy.dart'; | 8 import 'package:kernel/src/incremental_class_hierarchy.dart'; |
9 import 'package:kernel/testing/mock_sdk_program.dart'; | 9 import 'package:kernel/testing/mock_sdk_program.dart'; |
10 import 'package:kernel/text/ast_to_text.dart'; | 10 import 'package:kernel/text/ast_to_text.dart'; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 class C extends self::A implements self::B {} | 282 class C extends self::A implements self::B {} |
283 class D {} | 283 class D {} |
284 class E = self::D with self::A implements self::B {} | 284 class E = self::D with self::A implements self::B {} |
285 '''); | 285 '''); |
286 | 286 |
287 _assertOverridePairs(c, ['test::A::foo overrides test::B::foo']); | 287 _assertOverridePairs(c, ['test::A::foo overrides test::B::foo']); |
288 _assertOverridePairs(e, ['test::A::foo overrides test::B::foo']); | 288 _assertOverridePairs(e, ['test::A::foo overrides test::B::foo']); |
289 } | 289 } |
290 | 290 |
| 291 /// An abstract member declared in the class is overridden by a member in |
| 292 /// one of the interfaces. |
| 293 void test_forEachOverridePair_supertypeOverridesThis() { |
| 294 var a = addClass(new Class( |
| 295 name: 'A', |
| 296 supertype: objectSuper, |
| 297 procedures: [newEmptyMethod('foo')])); |
| 298 var b = addClass(new Class( |
| 299 name: 'B', |
| 300 supertype: a.asThisSupertype, |
| 301 procedures: [newEmptyMethod('foo', isAbstract: true)])); |
| 302 var c = addClass(new Class( |
| 303 name: 'C', |
| 304 supertype: a.asThisSupertype, |
| 305 procedures: [newEmptyMethod('foo', isAbstract: true)], |
| 306 isAbstract: true)); |
| 307 |
| 308 _assertTestLibraryText(''' |
| 309 class A { |
| 310 method foo() → void {} |
| 311 } |
| 312 class B extends self::A { |
| 313 abstract method foo() → void; |
| 314 } |
| 315 abstract class C extends self::A { |
| 316 abstract method foo() → void; |
| 317 } |
| 318 '''); |
| 319 |
| 320 _assertOverridePairs(b, [ |
| 321 'test::A::foo overrides test::B::foo', |
| 322 'test::B::foo overrides test::A::foo' |
| 323 ]); |
| 324 _assertOverridePairs(c, [ |
| 325 'test::A::foo overrides test::C::foo', |
| 326 'test::C::foo overrides test::A::foo' |
| 327 ]); |
| 328 } |
| 329 |
291 /// 3. A non-abstract member is inherited from a superclass, and it overrides | 330 /// 3. A non-abstract member is inherited from a superclass, and it overrides |
292 /// an abstract member declared in this class. | 331 /// an abstract member declared in this class. |
293 void test_forEachOverridePair_supertypeOverridesThisAbstract() { | 332 void test_forEachOverridePair_supertypeOverridesThisAbstract() { |
294 var a = addClass(new Class( | 333 var a = addClass(new Class( |
295 name: 'A', | 334 name: 'A', |
296 supertype: objectSuper, | 335 supertype: objectSuper, |
297 procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')])); | 336 procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')])); |
298 var b = addClass(new Class( | 337 var b = addClass(new Class( |
299 name: 'B', | 338 name: 'B', |
300 supertype: a.asThisSupertype, | 339 supertype: a.asThisSupertype, |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 actualText = actualText.replaceAll(' extends core::Object', ''); | 1339 actualText = actualText.replaceAll(' extends core::Object', ''); |
1301 | 1340 |
1302 if (actualText != expectedText) { | 1341 if (actualText != expectedText) { |
1303 print('-------- Actual --------'); | 1342 print('-------- Actual --------'); |
1304 print(actualText + '------------------------'); | 1343 print(actualText + '------------------------'); |
1305 } | 1344 } |
1306 | 1345 |
1307 expect(actualText, expectedText); | 1346 expect(actualText, expectedText); |
1308 } | 1347 } |
1309 } | 1348 } |
OLD | NEW |