Support generic methods in reflection.

Closes #28240

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2613433002 .
This commit is contained in:
Johnni Winther 2017-01-04 10:32:19 +01:00
parent a510d4fd3e
commit 72e3e0c006
3 changed files with 11 additions and 9 deletions

View file

@ -679,11 +679,14 @@ class ReflectionInfo {
if (JS('bool', 'typeof # == "number"', functionType)) {
return getType(functionType);
} else if (JS('bool', 'typeof # == "function"', functionType)) {
var fakeInstance = JS('', 'new #()', jsConstructor);
setRuntimeTypeInfo(
fakeInstance, JS('JSExtendableArray', '#["<>"]', fakeInstance));
return JS('=Object|Null', r'#.apply({$receiver:#})',
functionType, fakeInstance);
if (jsConstructor != null) {
var fakeInstance = JS('', 'new #()', jsConstructor);
setRuntimeTypeInfo(
fakeInstance, JS('JSExtendableArray', '#["<>"]', fakeInstance));
return JS('=Object|Null', r'#.apply({$receiver:#})',
functionType, fakeInstance);
}
return functionType;
} else {
throw new RuntimeError('Unexpected function type');
}

View file

@ -121,4 +121,4 @@ constant_javascript_semantics2_test: Pass, Slow # Issue 25940
consistent_index_error_string_test: Pass, Slow # Issue 25940
[ $compiler == dart2js ]
mirror_printer_test: Fail # Issue 28240, was: Pass, Slow # Issue 25940, 16473
mirror_printer_test: Pass, Slow # Issue 25940, 16473

View file

@ -20,8 +20,7 @@ import 'dart:mirrors';
import 'crash_library_metadata.dart'; // This would crash dart2js.
// Importing dart:html to make things interesting.
// TODO(johnniwinther): Reenable this when #28240 has been fixed.
// import 'dart:html';
import 'dart:html'; /// 01: ok
class MirrorPrinter {
final StringBuffer buffer;
@ -186,5 +185,5 @@ main() {
print(MirrorPrinter.stringify(currentMirrorSystem().libraries));
// Clear the nodes to avoid confusing the fine test framework (by "fine" I
// mean something else) -- ahe.
document.body.nodes.clear();
document.body.nodes.clear(); /// 01: continued
}