| 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 /** 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 | 8 |
| 9 String name; | 9 String name; |
| 10 Type type; | 10 Type type; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 if (definition.value != null) { | 30 if (definition.value != null) { |
| 31 // To match VM, detect cases where value was not actually specified in | 31 // To match VM, detect cases where value was not actually specified in |
| 32 // code and don't signal errors. | 32 // code and don't signal errors. |
| 33 // TODO(jimhug): Clean up after issue #352 is resolved. | 33 // TODO(jimhug): Clean up after issue #352 is resolved. |
| 34 if (definition.value is NullExpression && | 34 if (definition.value is NullExpression && |
| 35 definition.value.span.start == definition.span.start) { | 35 definition.value.span.start == definition.span.start) { |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 if (method.isAbstract) { | 38 if (method.name == '\$call') { |
| 39 world.error('default value not allowed on abstract methods', | |
| 40 definition.span); | |
| 41 } else if (method.name == '\$call' && method.definition.body == null) { | |
| 42 // TODO(jimhug): Need simpler way to detect "true" function types vs. | 39 // TODO(jimhug): Need simpler way to detect "true" function types vs. |
| 43 // regular methods being used as function types for closures. | 40 // regular methods being used as function types for closures. |
| 44 world.error('default value not allowed on function type', | 41 if (method.definition.body == null) { |
| 42 world.error('default value not allowed on function type', |
| 43 definition.span); |
| 44 } |
| 45 } else if (method.isAbstract) { |
| 46 world.error('default value not allowed on abstract methods', |
| 45 definition.span); | 47 definition.span); |
| 46 } | 48 } |
| 47 } else if (isInitializer && !method.isConstructor) { | 49 } else if (isInitializer && !method.isConstructor) { |
| 48 world.error('initializer parameters only allowed on constructors', | 50 world.error('initializer parameters only allowed on constructors', |
| 49 definition.span); | 51 definition.span); |
| 50 } | 52 } |
| 51 } | 53 } |
| 52 | 54 |
| 53 genValue(MethodMember method, MethodGenerator context) { | 55 genValue(MethodMember method, MethodGenerator context) { |
| 54 if (definition.value == null || value != null) return; | 56 if (definition.value == null || value != null) return; |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 } | 1696 } |
| 1695 | 1697 |
| 1696 void forEach(void f(Member member)) { | 1698 void forEach(void f(Member member)) { |
| 1697 factories.forEach((_, Map constructors) { | 1699 factories.forEach((_, Map constructors) { |
| 1698 constructors.forEach((_, Member member) { | 1700 constructors.forEach((_, Member member) { |
| 1699 f(member); | 1701 f(member); |
| 1700 }); | 1702 }); |
| 1701 }); | 1703 }); |
| 1702 } | 1704 } |
| 1703 } | 1705 } |
| OLD | NEW |