OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.type; | 4 package com.google.dart.compiler.type; |
5 | 5 |
6 import com.google.common.base.Joiner; | 6 import com.google.common.base.Joiner; |
7 import com.google.common.collect.Iterables; | 7 import com.google.common.collect.Iterables; |
8 import com.google.common.collect.Lists; | 8 import com.google.common.collect.Lists; |
9 import com.google.common.collect.Maps; | 9 import com.google.common.collect.Maps; |
10 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; | 10 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 "interface I {", | 1485 "interface I {", |
1486 " foo([x,y]);", | 1486 " foo([x,y]);", |
1487 "}", | 1487 "}", |
1488 "class C implements I {", | 1488 "class C implements I {", |
1489 " foo([x]) {}", | 1489 " foo([x]) {}", |
1490 "}"); | 1490 "}"); |
1491 assertErrors( | 1491 assertErrors( |
1492 result.getErrors(), | 1492 result.getErrors(), |
1493 errEx(ResolverErrorCode.CANNOT_OVERRIDE_METHOD_NAMED_PARAMS, 5, 3, 3)); | 1493 errEx(ResolverErrorCode.CANNOT_OVERRIDE_METHOD_NAMED_PARAMS, 5, 3, 3)); |
1494 } | 1494 } |
| 1495 |
| 1496 public void test_metadataOverride_OK_method() throws Exception { |
| 1497 AnalyzeLibraryResult result = analyzeLibrary( |
| 1498 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 1499 "class A {", |
| 1500 " foo() {}", |
| 1501 "}", |
| 1502 "class B extends A {", |
| 1503 " // @override", |
| 1504 " foo() {}", |
| 1505 "}", |
| 1506 ""); |
| 1507 assertErrors(result.getErrors()); |
| 1508 } |
| 1509 |
| 1510 public void test_metadataOverride_Bad_method() throws Exception { |
| 1511 AnalyzeLibraryResult result = analyzeLibrary( |
| 1512 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 1513 "class A {", |
| 1514 "}", |
| 1515 "class B extends A {", |
| 1516 " // @override", |
| 1517 " foo() {}", |
| 1518 "}", |
| 1519 ""); |
| 1520 assertErrors( |
| 1521 result.getErrors(), |
| 1522 errEx(ResolverErrorCode.INVALID_OVERRIDE_METADATA, 6, 3, 3)); |
| 1523 } |
1495 | 1524 |
1496 /** | 1525 /** |
1497 * It is a compile-time error if an instance method m1 overrides an instance m
ember m2 and m1 does | 1526 * It is a compile-time error if an instance method m1 overrides an instance m
ember m2 and m1 does |
1498 * not declare all the named parameters declared by m2 in the same order. | 1527 * not declare all the named parameters declared by m2 in the same order. |
1499 * <p> | 1528 * <p> |
1500 * Here: wrong order. | 1529 * Here: wrong order. |
1501 */ | 1530 */ |
1502 public void testImplementsAndOverrides5() throws Exception { | 1531 public void testImplementsAndOverrides5() throws Exception { |
1503 AnalyzeLibraryResult result = | 1532 AnalyzeLibraryResult result = |
1504 analyzeLibrary( | 1533 analyzeLibrary( |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 && index < sourceInfo.getEnd() | 2893 && index < sourceInfo.getEnd() |
2865 && clazz.isInstance(node)) { | 2894 && clazz.isInstance(node)) { |
2866 result.set((T) node); | 2895 result.set((T) node); |
2867 } | 2896 } |
2868 return super.visitNode(node); | 2897 return super.visitNode(node); |
2869 } | 2898 } |
2870 }); | 2899 }); |
2871 return result.get(); | 2900 return result.get(); |
2872 } | 2901 } |
2873 } | 2902 } |
OLD | NEW |