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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 12210138: Add substitution for classes that use type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add deleted newline again. Created 7 years, 10 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
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 25cba58e1f4b7a96b2f80ca714f420482ae94ebd..61f532e788af9c9594e51e7f7ac3cdd8436a34d8 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -1066,9 +1066,9 @@ getRuntimeTypeInfo(target) {
return JS('var', r'#.$builtinTypeInfo', target);
}
-getRuntimeTypeArgument(target, index) {
- var rti = getRuntimeTypeInfo(target);
- return (rti != null) ? JS('var', r'#[#]', rti, index) : null;
+getRuntimeTypeArgument(target, substitution, index) {
+ var arguments = substitute(substitution, getRuntimeTypeInfo(target));
+ return (arguments == null) ? null : getField(arguments, index);
}
/**
@@ -1478,6 +1478,15 @@ Object invoke(function, arguments) {
return JS('var', r'#.apply(null, #)', function, arguments);
}
+substitute(var substitution, var arguments) {
+ if (isJsArray(substitution)) {
+ arguments = substitution;
+ } else if (isJsFunction(substitution)) {
+ arguments = invoke(substitution, arguments);
+ }
+ return arguments;
+}
+
/**
* Check that the types in the list [arguments] are subtypes of the types in
* list [checks] (at the respective positions), possibly applying [substitution]
@@ -1487,12 +1496,7 @@ Object invoke(function, arguments) {
* values for [substitution].
*/
bool checkArguments(var substitution, var arguments, var checks) {
- if (isJsArray(substitution)) {
- arguments = substitution;
- } else if (isJsFunction(substitution)) {
- arguments = invoke(substitution, arguments);
- }
- return areSubtypes(arguments, checks);
+ return areSubtypes(substitute(substitution, arguments), checks);
}
bool areSubtypes(List s, List t) {
@@ -1514,7 +1518,7 @@ bool areSubtypes(List s, List t) {
getArguments(var type) => JS('var', r'#.slice(1)', type);
-getField(var object, String name) => JS('var', r'#[#]', object, name);
+getField(var object, var name) => JS('var', r'#[#]', object, name);
/**
* Check whether the type represented by [s] is a subtype of the type

Powered by Google App Engine
This is Rietveld 408576698