Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/compiler/dart2js/resolver_test.dart

Issue 1089463003: Do not use erroneouselement unless the member is static (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import "package:compiler/src/resolution/resolution.dart"; 10 import "package:compiler/src/resolution/resolution.dart";
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 expect(compiler, 1138 expect(compiler,
1139 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], 1139 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
1140 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1140 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1141 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1141 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1142 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, 1142 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
1143 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); 1143 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
1144 })); 1144 }));
1145 } 1145 }
1146 1146
1147 testCantAssignMethods() { 1147 testCantAssignMethods() {
1148 checkWarningOn(String script, List<String> errorLocations) { 1148 checkWarningOn(String script, List<MessageKind> warnings) {
1149 Expect.isTrue(warnings.length >= 0 && warnings.length <= 2);
1149 asyncTest(() => compileScript(script).then((compiler) { 1150 asyncTest(() => compileScript(script).then((compiler) {
1150 Expect.equals(0, compiler.errors.length); 1151 Expect.equals(0, compiler.errors.length);
1151 Expect.equals(errorLocations.length, compiler.warnings.length); 1152 Expect.equals(warnings.length, compiler.warnings.length);
1152 for (var i = 0; i < errorLocations.length; i++) { 1153 for (int i = 0; i < warnings.length; i++) {
1153 Expect.equals(MessageKind.ASSIGNING_METHOD, 1154 Expect.equals(warnings[i], compiler.warnings[i].message.kind);
1154 compiler.warnings[i].message.kind);
1155 Expect.equals(script.indexOf(errorLocations[i]),
1156 compiler.warnings[i].node.getBeginToken().charOffset);
1157 } 1155 }
1158 })); 1156 }));
1159 } 1157 }
1160 1158
1161 // Can't override local functions 1159 // Can't override local functions
1162 checkWarningOn(''' 1160 checkWarningOn('''
1163 main() { 1161 main() {
1164 mname() { mname = 2; }; 1162 mname() { mname = 2; };
1165 mname(); 1163 mname();
1166 } 1164 }
1167 ''', ['mname = 2']); 1165 ''', [MessageKind.ASSIGNING_METHOD]);
1168 1166
1169 checkWarningOn(''' 1167 checkWarningOn('''
1170 main() { 1168 main() {
1171 mname() { }; 1169 mname() { };
1172 mname = 3; 1170 mname = 3;
1173 } 1171 }
1174 ''', ['mname = 3']); 1172 ''', [MessageKind.ASSIGNING_METHOD]);
1175 1173
1176 // Can't override top-level functions 1174 // Can't override top-level functions
1177 checkWarningOn(''' 1175 checkWarningOn('''
1178 m() {} 1176 m() {}
1179 main() { m = 4; } 1177 main() { m = 4; }
1180 ''', ['m = 4']); 1178 ''', [MessageKind.ASSIGNING_METHOD]);
1181 1179
1182 // Can't override instance methods 1180 // Can't override instance methods
1183 checkWarningOn(''' 1181 checkWarningOn('''
1184 main() { new B().bar(); } 1182 main() { new B().bar(); }
1185 class B { 1183 class B {
1186 mname() {} 1184 mname() {}
1187 bar() { 1185 bar() {
1188 mname = () => null; 1186 mname = () => null;
1189 } 1187 }
1190 } 1188 }
1191 ''', ['mname = () => null']); 1189 ''', [MessageKind.ASSIGNING_METHOD, MessageKind.SETTER_NOT_FOUND]);
Siggi Cherem (dart-lang) 2015/04/15 01:38:04 I'm not happy with the second error (which is curr
Johnni Winther 2015/04/15 08:58:03 Actually should not resolve [target] to an instanc
Siggi Cherem (dart-lang) 2015/04/15 22:39:46 Good point - I changed it so that the checker repo
1192 1190
1193 // Can't override super methods 1191 // Can't override super methods
1194 checkWarningOn(''' 1192 checkWarningOn('''
1195 main() { new B().bar(); } 1193 main() { new B().bar(); }
1196 class A { 1194 class A {
1197 mname() {} 1195 mname() {}
1198 } 1196 }
1199 class B extends A { 1197 class B extends A {
1200 bar() { 1198 bar() {
1201 super.mname = () => 6; 1199 super.mname = () => 6;
1202 } 1200 }
1203 } 1201 }
1204 ''', ['mname = () => 6']); 1202 ''', [MessageKind.ASSIGNING_METHOD, MessageKind.SETTER_NOT_FOUND]);
1205 1203
1206 // But fields are OK: 1204 // But fields are OK:
1207 checkWarningOn(''' 1205 checkWarningOn('''
1208 main() { new B().bar(); } 1206 main() { new B().bar(); }
1209 class A { 1207 class A {
1210 int fname; 1208 int fname;
1211 } 1209 }
1212 class B extends A { 1210 class B extends A {
1213 bar() { 1211 bar() {
1214 super.fname = 3; 1212 super.fname = 3;
(...skipping 16 matching lines...) Expand all
1231 class A { 1229 class A {
1232 operator[]=(x, y) {} 1230 operator[]=(x, y) {}
1233 } 1231 }
1234 class B extends A { 1232 class B extends A {
1235 bar() { 1233 bar() {
1236 super[1] = 3; // This is OK 1234 super[1] = 3; // This is OK
1237 } 1235 }
1238 } 1236 }
1239 ''', []); 1237 ''', []);
1240 } 1238 }
OLDNEW
« pkg/compiler/lib/src/resolution/members.dart ('K') | « tests/co19/co19-dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698