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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 23020025: Implement ParameterMirror.{isFinal,hasDefaultValue,defaultValue}. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index ea63f9079e4d381b0ac2b2965447296bc1a3cce4..19c8520665b4359eea5f6100fcd12bd74808ebad 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -1077,27 +1077,30 @@ class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
DeclarationMirror owner,
this._position,
this.isOptional,
- this.isNamed)
+ this.isNamed,
+ bool isFinal,
+ this._defaultValueReflectee)
: super(reflectee,
simpleName,
owner,
null, // We override the type.
false, // isStatic does not apply.
- false); // TODO(12196): Not yet implemented.
+ isFinal);
final int _position;
final bool isOptional;
final bool isNamed;
- String get defaultValue {
- throw new UnimplementedError(
- 'ParameterMirror.defaultValue is not implemented');
+ Object _defaultValueReflectee;
+ InstanceMirror _defaultValue = null;
+ InstanceMirror get defaultValue {
+ if (_defaultValue == null && isOptional) {
+ _defaultValue = reflect(_defaultValueReflectee);
+ }
siva 2013/08/26 05:05:43 Maybe write as: if (!isOptional) { return false
Michael Lippautz (Google) 2013/08/26 19:45:57 Rewrote using this pattern, with the difference th
+ return _defaultValue;
}
- bool get hasDefaultValue {
- throw new UnimplementedError(
- 'ParameterMirror.hasDefaultValue is not implemented');
- }
+ bool get hasDefaultValue => _defaultValueReflectee != null;
// TODO(11418): Implement.
List<InstanceMirror> get metadata {

Powered by Google App Engine
This is Rietveld 408576698