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

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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index 498e4698bac865b42ea7282e64a763b3a064d0e4..4d211ec92db990fba528430ce4ae3ce70a20e5a6 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -1089,27 +1089,33 @@ 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;
+ InstanceMirror get defaultValue {
+ if (!isOptional) {
+ return null;
+ }
+ if (_defaultValue == null) {
+ _defaultValue = reflect(_defaultValueReflectee);
+ }
+ 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 {
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698