Fix non-specific type parameter in member maps.

BUG=http://dartbug.com/14972
R=regis@google.com

Review URL: https://codereview.chromium.org//140313005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32225 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
rmacnak@google.com 2014-01-31 23:52:15 +00:00
parent f54884a848
commit 2da8c830a3
2 changed files with 35 additions and 3 deletions

View file

@ -52,8 +52,9 @@ Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) {
}
Map _makeMemberMap(List mirrors) {
return new _UnmodifiableMapView(
new Map<Symbol, dynamic>.fromIterable(mirrors, key: (e) => e.simpleName));
return new _UnmodifiableMapView<Symbol, DeclarationMirror>(
new Map<Symbol, DeclarationMirror>.fromIterable(
mirrors, key: (e) => e.simpleName));
}
String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
@ -653,7 +654,8 @@ class _LocalClassMirror extends _LocalObjectMirror
var constructorsList = _computeConstructors(_reflectee);
var stringName = _n(simpleName);
constructorsList.forEach((c) => c._patchConstructorName(stringName));
_cachedConstructors = _makeMemberMap(constructorsList);
_cachedConstructors =
new Map.fromIterable(constructorsList, key: (e) => e.simpleName);
}
return _cachedConstructors;
}

View file

@ -0,0 +1,30 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// 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.
// Regression test for Issue 14972.
library test.declarations_type;
import 'dart:mirrors';
import 'package:expect/expect.dart';
class C {}
main() {
var classDeclarations = reflectClass(C).declarations;
Expect.isTrue(classDeclarations is Map<Symbol, DeclarationMirror>);
Expect.isTrue(classDeclarations.values is Iterable<DeclarationMirror>);
Expect.isTrue(classDeclarations.values.where((x) => true) is Iterable<DeclarationMirror>);
Expect.isFalse(classDeclarations is Map<Symbol, MethodMirror>);
Expect.isFalse(classDeclarations.values is Iterable<MethodMirror>);
Expect.isFalse(classDeclarations.values.where((x) => true) is Iterable<MethodMirror>);
var libraryDeclarations = (reflectClass(C).owner as LibraryMirror).declarations;
Expect.isTrue(libraryDeclarations is Map<Symbol, DeclarationMirror>);
Expect.isTrue(libraryDeclarations.values is Iterable<DeclarationMirror>);
Expect.isTrue(libraryDeclarations.values.where((x) => true) is Iterable<DeclarationMirror>);
Expect.isFalse(libraryDeclarations is Map<Symbol, ClassMirror>);
Expect.isFalse(libraryDeclarations.values is Iterable<ClassMirror>);
Expect.isFalse(libraryDeclarations.values.where((x) => true) is Iterable<ClassMirror>);
}