| 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 | 4 |
| 5 /** A formal parameter to a [Method]. */ | 5 /** A formal parameter to a [Method]. */ |
| 6 class Parameter { | 6 class Parameter { |
| 7 FormalNode definition; | 7 FormalNode definition; |
| 8 Member method; | 8 Member method; |
| 9 | 9 |
| 10 String name; | 10 String name; |
| (...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 } | 1228 } |
| 1229 } else { | 1229 } else { |
| 1230 if (definition.body == null && !isConstructor && !isNative) { | 1230 if (definition.body == null && !isConstructor && !isNative) { |
| 1231 world.error('method needs a body', span); | 1231 world.error('method needs a body', span); |
| 1232 } | 1232 } |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 if (isConstructor && !isFactory) { | 1235 if (isConstructor && !isFactory) { |
| 1236 returnType = declaringType; | 1236 returnType = declaringType; |
| 1237 } else { | 1237 } else { |
| 1238 returnType = resolveType(definition.returnType, false); | 1238 // This is the one and only place we allow void. |
| 1239 returnType = resolveType(definition.returnType, false, allowVoid: true); |
| 1239 } | 1240 } |
| 1240 parameters = []; | 1241 parameters = []; |
| 1241 for (var formal in definition.formals) { | 1242 for (var formal in definition.formals) { |
| 1242 // TODO(jimhug): Clean up construction of Parameters. | 1243 // TODO(jimhug): Clean up construction of Parameters. |
| 1243 var param = new Parameter(formal, this); | 1244 var param = new Parameter(formal, this); |
| 1244 param.resolve(); | 1245 param.resolve(); |
| 1245 parameters.add(param); | 1246 parameters.add(param); |
| 1246 } | 1247 } |
| 1247 | 1248 |
| 1248 if (!isLambda) { | 1249 if (!isLambda) { |
| 1249 library._addMember(this); | 1250 library._addMember(this); |
| 1250 } | 1251 } |
| 1251 } | 1252 } |
| 1252 | 1253 |
| 1253 /** Overriden to ensure that type arguments aren't used in static methods. */ | 1254 /** Overriden to ensure that type arguments aren't used in static methods. */ |
| 1254 Type resolveType(TypeReference node, bool typeErrors) { | 1255 Type resolveType(TypeReference node, bool typeErrors, |
| 1256 [bool allowVoid = false]) { |
| 1255 Type t = super.resolveType(node, typeErrors); | 1257 Type t = super.resolveType(node, typeErrors); |
| 1256 if (isStatic && !isFactory && t is ParameterType) { | 1258 if (isStatic && !isFactory && t is ParameterType) { |
| 1257 world.error('using type parameter in static context.', node.span); | 1259 world.error('using type parameter in static context.', node.span); |
| 1258 } | 1260 } |
| 1261 if (!allowVoid && t.isVoid) { |
| 1262 world.error('"void" only allowed as return type', node.span); |
| 1263 } |
| 1259 return t; | 1264 return t; |
| 1260 } | 1265 } |
| 1261 } | 1266 } |
| 1262 | 1267 |
| 1263 | 1268 |
| 1264 class MemberSet { | 1269 class MemberSet { |
| 1265 final String name; | 1270 final String name; |
| 1266 final List<Member> members; | 1271 final List<Member> members; |
| 1267 final String jsname; | 1272 final String jsname; |
| 1268 final bool isVar; | 1273 final bool isVar; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 } | 1591 } |
| 1587 | 1592 |
| 1588 void forEach(void f(Member member)) { | 1593 void forEach(void f(Member member)) { |
| 1589 factories.forEach((_, Map constructors) { | 1594 factories.forEach((_, Map constructors) { |
| 1590 constructors.forEach((_, Member member) { | 1595 constructors.forEach((_, Member member) { |
| 1591 f(member); | 1596 f(member); |
| 1592 }); | 1597 }); |
| 1593 }); | 1598 }); |
| 1594 } | 1599 } |
| 1595 } | 1600 } |
| OLD | NEW |