mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 00:23:57 +00:00
Make type variables belong to the original declaration in VM.
BUG=http://dartbug.com/14240 R=gbracha@google.com, zarah@google.com Review URL: https://codereview.chromium.org//35543007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29106 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
ec40463cb1
commit
ccfaa29881
|
@ -666,10 +666,11 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
|
|||
_typeVariables = new List<TypeVariableMirror>();
|
||||
|
||||
List params = _ClassMirror_type_variables(_reflectee);
|
||||
ClassMirror owner = originalDeclaration;
|
||||
var mirror;
|
||||
for (var i = 0; i < params.length; i += 2) {
|
||||
mirror = new _LocalTypeVariableMirrorImpl(
|
||||
params[i + 1], params[i], this);
|
||||
params[i + 1], params[i], owner);
|
||||
_typeVariables.add(mirror);
|
||||
}
|
||||
_typeVariables = new UnmodifiableListView(_typeVariables);
|
||||
|
@ -906,7 +907,7 @@ class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl
|
|||
DeclarationMirror _owner;
|
||||
DeclarationMirror get owner {
|
||||
if (_owner == null) {
|
||||
_owner = _TypeVariableMirror_owner(_reflectee);
|
||||
_owner = _TypeVariableMirror_owner(_reflectee).originalDeclaration;
|
||||
}
|
||||
return _owner;
|
||||
}
|
||||
|
@ -1023,10 +1024,11 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl
|
|||
if (_typeVariables == null) {
|
||||
_typeVariables = new List<TypeVariableMirror>();
|
||||
List params = _LocalClassMirrorImpl._ClassMirror_type_variables(_reflectee);
|
||||
TypedefMirror owner = originalDeclaration;
|
||||
var mirror;
|
||||
for (var i = 0; i < params.length; i += 2) {
|
||||
mirror = new _LocalTypeVariableMirrorImpl(
|
||||
params[i + 1], params[i], this);
|
||||
params[i + 1], params[i], owner);
|
||||
_typeVariables.add(mirror);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ mirrors/type_argument_is_type_variable_test: RuntimeError # Issue 12333
|
|||
mirrors/typedef_test/none: RuntimeError # http://dartbug.com/6490
|
||||
mirrors/typedef_metadata_test: RuntimeError # Issue 12785
|
||||
mirrors/typevariable_mirror_metadata_test: CompileTimeError # Issue 10905
|
||||
mirrors/type_variable_owner_test/01: RuntimeError # Issue 12785
|
||||
mirrors/unnamed_library_test: RuntimeError # Issue 10580
|
||||
|
||||
[ $compiler == dart2js && $unchecked ]
|
||||
|
@ -175,9 +176,6 @@ mirrors/typedef_test/01: Fail, OK # Incorrect dart2js behavior.
|
|||
|
||||
mirrors/generic_f_bounded_test/01: RuntimeError # Issue 14000
|
||||
mirrors/symbol_validation_test: RuntimeError # Issue 13596
|
||||
mirrors/typevariable_mirror_metadata_test/none: RuntimeError # Issue 12282
|
||||
mirrors/type_variable_owner_test: RuntimeError # Issue 14240
|
||||
mirrors/class_mirror_type_variables_test/01: RuntimeError # Issue 14240
|
||||
|
||||
async/timer_isolate_test: Skip # See Issue 4997
|
||||
async/timer_not_available_test: SkipByDesign # only meant to test when there is no way to implement timer (currently only in d8)
|
||||
|
@ -213,6 +211,7 @@ mirrors/generic_f_bounded_mixin_application_test: Fail # Issue 14116
|
|||
mirrors/generic_interface_test/none: Fail # Inexpressible in multitest
|
||||
mirrors/typevariable_mirror_metadata_test/none: Fail # Issue 13093
|
||||
mirrors/redirecting_factory_test/none: Fail # Issue 14285
|
||||
mirrors/type_variable_owner_test/none: Fail # Issue 14356
|
||||
|
||||
[ $compiler == dart2analyzer ]
|
||||
mirrors/typedef_test/none: Fail # Issue 13093
|
||||
|
@ -223,6 +222,7 @@ mirrors/generic_mixin_test/none: Fail # Issue 13432
|
|||
mirrors/invoke_named_test/none: Fail # http://dartbug.com/13612
|
||||
mirrors/generic_f_bounded_mixin_application_test: Fail # Issue 14116
|
||||
mirrors/generic_interface_test/none: Fail # Inexpressible in multitest
|
||||
mirrors/type_variable_owner_test/none: Fail # Issue 14356
|
||||
|
||||
[ $compiler == none && $runtime == dartium ]
|
||||
async/schedule_microtask5_test: Pass, Timeout # Issue 13719: Please triage this failure.
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Owner of a type variable should be the declaration of the generic class or
|
||||
// typedef, not an instantiation.
|
||||
|
||||
library test.type_variable_owner;
|
||||
|
||||
import "dart:mirrors";
|
||||
|
@ -11,7 +14,7 @@ import "package:expect/expect.dart";
|
|||
class A<T> {}
|
||||
class B<R> extends A<R> {}
|
||||
|
||||
main() {
|
||||
testTypeVariableOfClass() {
|
||||
ClassMirror aDecl = reflectClass(A);
|
||||
ClassMirror bDecl = reflectClass(B);
|
||||
ClassMirror aOfInt = reflect(new A<int>()).type;
|
||||
|
@ -19,9 +22,6 @@ main() {
|
|||
ClassMirror bOfString = reflect(new B<String>()).type;
|
||||
ClassMirror aOfString = bOfString.superclass;
|
||||
|
||||
// Owner of a type variable should be the declaration of the generic class,
|
||||
// not an instantiation.
|
||||
|
||||
Expect.equals(aDecl, aDecl.typeVariables[0].owner);
|
||||
Expect.equals(aDecl, aOfInt.typeVariables[0].owner);
|
||||
Expect.equals(aDecl, aOfR.typeVariables[0].owner);
|
||||
|
@ -30,3 +30,25 @@ main() {
|
|||
Expect.equals(bDecl, bDecl.typeVariables[0].owner);
|
||||
Expect.equals(bDecl, bOfString.typeVariables[0].owner);
|
||||
}
|
||||
|
||||
typedef bool Predicate<T>(T t);
|
||||
Predicate<List> somePredicateOfList;
|
||||
|
||||
testTypeVariableOfTypedef() {
|
||||
LibraryMirror thisLibrary =
|
||||
currentMirrorSystem().findLibrary(#test.type_variable_owner).single;
|
||||
|
||||
TypedefMirror predicateOfDynamic = reflectType(Predicate);
|
||||
TypedefMirror predicateOfList =
|
||||
thisLibrary.variables[#somePredicateOfList].type;
|
||||
TypedefMirror predicateDecl = predicateOfList.originalDeclaration;
|
||||
|
||||
Expect.equals(predicateDecl, predicateOfDynamic.typeVariables[0].owner);
|
||||
Expect.equals(predicateDecl, predicateOfList.typeVariables[0].owner);
|
||||
Expect.equals(predicateDecl, predicateDecl.typeVariables[0].owner);
|
||||
}
|
||||
|
||||
main() {
|
||||
testTypeVariableOfClass();
|
||||
testTypeVariableOfTypedef(); /// 01: ok
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue