OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
6 | 6 |
7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
8 import com.google.dart.compiler.DartCompilationError; | 8 import com.google.dart.compiler.DartCompilationError; |
9 import com.google.dart.compiler.ErrorCode; | 9 import com.google.dart.compiler.ErrorCode; |
10 import com.google.dart.compiler.ast.DartClass; | 10 import com.google.dart.compiler.ast.DartClass; |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 "class int {}", | 979 "class int {}", |
980 "typedef Dynamic F1<T>(Dynamic x, T y);", | 980 "typedef Dynamic F1<T>(Dynamic x, T y);", |
981 "class MyClass {", | 981 "class MyClass {", |
982 " main() {", | 982 " main() {", |
983 " F1<int> f1 = (Object o, int i) => null;", | 983 " F1<int> f1 = (Object o, int i) => null;", |
984 " if (f1 is F1<int>) {", | 984 " if (f1 is F1<int>) {", |
985 " }", | 985 " }", |
986 " }", | 986 " }", |
987 "}")); | 987 "}")); |
988 } | 988 } |
| 989 |
| 990 public void testImplementsAndOverrides1() { |
| 991 resolveAndTest(Joiner.on("\n").join( |
| 992 "class Object {}", |
| 993 "interface Interface {", |
| 994 " foo(x);", |
| 995 "}", |
| 996 "class Class implements Interface {", |
| 997 " foo() {}", // error |
| 998 "}"), |
| 999 ResolverErrorCode.CANNOT_OVERRIDE_METHOD_WRONG_NUM_PARAMS); |
| 1000 } |
| 1001 |
| 1002 public void testImplementsAndOverrides2() { |
| 1003 resolveAndTest(Joiner.on("\n").join( |
| 1004 "class Object {}", |
| 1005 "interface Interface {", |
| 1006 " foo([x]);", |
| 1007 "}", |
| 1008 "class Class implements Interface {", |
| 1009 " foo([x,y]) {}", // error |
| 1010 "}"), |
| 1011 ResolverErrorCode.CANNOT_OVERRIDE_METHOD_WRONG_NUM_PARAMS); |
| 1012 } |
| 1013 |
| 1014 public void testImplementsAndOverrides3() { |
| 1015 resolveAndTest(Joiner.on("\n").join( |
| 1016 "class Object {}", |
| 1017 "interface Interface {", |
| 1018 " foo(x, [y]);", |
| 1019 "}", |
| 1020 "class Class implements Interface {", |
| 1021 " foo([x,y]) {}", // error |
| 1022 "}"), |
| 1023 ResolverErrorCode.CANNOT_OVERRIDE_METHOD_NUM_NAMED_PARAMS); |
| 1024 } |
| 1025 |
| 1026 public void testImplementsAndOverrides4() { |
| 1027 resolveAndTest(Joiner.on("\n").join( |
| 1028 "class Object {}", |
| 1029 "interface Interface {", |
| 1030 " foo([x,y]);", |
| 1031 "}", |
| 1032 "class Class implements Interface {", |
| 1033 " foo([x]) {}", // error |
| 1034 "}"), |
| 1035 ResolverErrorCode.CANNOT_OVERRIDE_METHOD_WRONG_NUM_PARAMS); |
| 1036 } |
| 1037 |
| 1038 public void testImplementsAndOverrides5() { |
| 1039 resolveAndTest(Joiner.on("\n").join( |
| 1040 "class Object {}", |
| 1041 "interface Interface {", |
| 1042 " foo([y,x]);", |
| 1043 "}", |
| 1044 "class Class implements Interface {", |
| 1045 " foo([x,y]) {}", // error |
| 1046 "}"), |
| 1047 ResolverErrorCode.CANNOT_OVERRIDE_METHOD_ORDER_NAMED_PARAMS); |
| 1048 } |
989 } | 1049 } |
OLD | NEW |