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

Side by Side Diff: frog/member.dart

Issue 8772070: Check constness of default args (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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) 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 Member method; 8 Member method;
9 9
10 String name; 10 String name;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 55
56 genValue(MethodMember method, MethodGenerator context) { 56 genValue(MethodMember method, MethodGenerator context) {
57 if (definition.value == null || value != null) return; 57 if (definition.value == null || value != null) return;
58 58
59 if (context == null) { // interface method 59 if (context == null) { // interface method
60 context = new MethodGenerator(method, null); 60 context = new MethodGenerator(method, null);
61 } 61 }
62 value = definition.value.visit(context); 62 value = definition.value.visit(context);
63 if (!value.isConst) {
64 world.error('default arguments must be constant', value.span);
jimhug 2011/12/06 16:23:39 Pet peeve: 'default parameter values must be const
65 }
63 value = value.convertTo(context, type, definition.value); 66 value = value.convertTo(context, type, definition.value);
64 } 67 }
65 68
66 Parameter copyWithNewType(Member newMethod, Type newType) { 69 Parameter copyWithNewType(Member newMethod, Type newType) {
67 var ret = new Parameter(definition, newMethod); 70 var ret = new Parameter(definition, newMethod);
68 ret.type = newType; 71 ret.type = newType;
69 ret.name = name; 72 ret.name = name;
70 ret.isInitializer = isInitializer; 73 ret.isInitializer = isInitializer;
71 return ret; 74 return ret;
72 } 75 }
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 } 1725 }
1723 1726
1724 void forEach(void f(Member member)) { 1727 void forEach(void f(Member member)) {
1725 factories.forEach((_, Map constructors) { 1728 factories.forEach((_, Map constructors) {
1726 constructors.forEach((_, Member member) { 1729 constructors.forEach((_, Member member) {
1727 f(member); 1730 f(member);
1728 }); 1731 });
1729 }); 1732 });
1730 } 1733 }
1731 } 1734 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698