Chromium Code Reviews| Index: runtime/lib/mirrors_impl.dart |
| diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart |
| index 9759d53bd15c4692176930bc5619fc94f937b65c..0165149beec030d446c04500a7e341cd0ee472c2 100644 |
| --- a/runtime/lib/mirrors_impl.dart |
| +++ b/runtime/lib/mirrors_impl.dart |
| @@ -433,6 +433,8 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| final bool _isMixinTypedef; |
| final bool _isGenericDeclaration; |
| + TypeMirror _instantiateInContextOf(declaration) => this; |
| + |
| bool get hasReflectedType => !_isGenericDeclaration; |
| Type get reflectedType { |
| if (!hasReflectedType) { |
| @@ -483,7 +485,9 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| ClassMirror _trueSuperclassField; |
| ClassMirror get _trueSuperclass { |
| if (_trueSuperclassField == null) { |
| - Type supertype = _supertype(_reflectee); |
| + Type supertype = isOriginalDeclaration |
| + ? _supertype(_reflectedType) |
|
rmacnak
2013/10/09 01:15:00
Unfortunately, this is not the same as reflecting
ahe
2013/10/10 16:53:38
Why?
rmacnak
2013/10/11 01:04:22
Consider
class S<T>
class C<R> extends S<R>
The s
ahe
2013/10/11 12:43:34
I'm not sure I understand this. What is the differ
|
| + : _supertypeInstantiated(_reflectedType); |
| if (supertype == null) { |
| // Object has no superclass. |
| return null; |
| @@ -596,11 +600,19 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| return _constructors; |
| } |
| + bool get _isAnonymousMixinApplication { |
| + if (_isMixinTypedef) return false; // Named mixin application. |
| + if (mixin == this) return false; // Not a mixin application. |
| + return true; |
| + } |
| + |
| List<TypeVariableMirror> _typeVariables = null; |
| List<TypeVariableMirror> get typeVariables { |
| if (_typeVariables == null) { |
| - List params = _ClassMirror_type_variables(_reflectee); |
| _typeVariables = new List<TypeVariableMirror>(); |
| + if (_isAnonymousMixinApplication) return _typeVariables; |
| + |
| + List params = _ClassMirror_type_variables(_reflectee); |
| var mirror; |
| for (var i = 0; i < params.length; i += 2) { |
| mirror = new _LocalTypeVariableMirrorImpl( |
| @@ -614,7 +626,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| List<TypeMirror> _typeArguments = null; |
| List<TypeMirror> get typeArguments { |
| if(_typeArguments == null) { |
| - if(_isGenericDeclaration) { |
| + if(_isGenericDeclaration || _isAnonymousMixinApplication) { |
| _typeArguments = new List<TypeMirror>(); |
| } else { |
| _typeArguments = |
| @@ -691,9 +703,12 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| static _library(reflectee) |
| native "ClassMirror_library"; |
| - static _supertype(reflectee) |
| + static _supertype(reflectedType) |
| native "ClassMirror_supertype"; |
| + static _supertypeInstantiated(reflectedType) |
| + native "ClassMirror_supertype_instantiated"; |
| + |
| static _interfaces(reflectee) |
| native "ClassMirror_interfaces"; |
| @@ -853,6 +868,22 @@ class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl |
| static Type _TypeVariableMirror_upper_bound(reflectee) |
| native "TypeVariableMirror_upper_bound"; |
| + |
| + static Type _TypeVariableMirror_instantiate_from(reflectee, instantator) |
|
regis
2013/10/09 15:46:51
instantiator
rmacnak
2013/10/11 01:04:22
Done.
|
| + native "TypeVariableMirror_instantiate_from"; |
| + |
| + TypeMirror _instantiateInContextOf(declaration) { |
| + var instantator = declaration; |
| + while (instantator is MethodMirror) instantator = instantator.owner; |
|
regis
2013/10/09 15:46:51
ditto
|
| + if (instantator is LibraryMirror) return this; |
| + if (instantator is! ClassMirror) throw "UNREACHABLE"; |
| + if (instantator.isOriginalDeclaration) return this; |
| + |
| + return _Mirrors._reflectType( |
| + _TypeVariableMirror_instantiate_from( |
| + _reflectee, |
| + instantator._reflectedType)); |
| + } |
| } |
| @@ -896,6 +927,9 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl |
| static _TypedefMirror_referent(_reflectee) |
| native "TypedefMirror_referent"; |
| + |
| + // TODO(12282): This is wrong. |
| + TypeMirror _instantiateInContextOf(declaration) => this; |
| } |
| class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
| @@ -1064,6 +1098,7 @@ class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl |
| _returnType = |
| _Mirrors._reflectType(_MethodMirror_return_type(_reflectee)); |
| } |
| + _returnType = _returnType._instantiateInContextOf(owner); |
| } |
| return _returnType; |
| } |
| @@ -1158,6 +1193,7 @@ class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl |
| TypeMirror get type { |
| if (_type == null) { |
| _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee)); |
| + _type = _type._instantiateInContextOf(owner); |
| } |
| return _type; |
| } |
| @@ -1215,6 +1251,7 @@ class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| if (_type == null) { |
| _type = |
| _Mirrors._reflectType(_ParameterMirror_type(_reflectee, _position)); |
| + _type = _type._instantiateInContextOf(owner); |
| } |
| return _type; |
| } |
| @@ -1254,6 +1291,8 @@ class _SpecialTypeMirrorImpl extends _LocalMirrorImpl |
| int get hashCode => simpleName.hashCode; |
| String toString() => "TypeMirror on '${_n(simpleName)}'"; |
| + |
| + TypeMirror _instantiateInContextOf(declaration) => this; |
| } |
| class _Mirrors { |