Add back missing cast failure cache on function types.

Casts for function types got moved off of the generic path, and hence
are missing the memo cache.  Added a second function type  cast cache.

Fixes #31392

Bug:
Change-Id: Ie1b87adf630f5059b57d01956778f5adde0533fc
Reviewed-on: https://dart-review.googlesource.com/21525
Reviewed-by: Vijay Menon <vsm@google.com>
This commit is contained in:
Leaf Petersen 2017-11-16 22:48:13 +00:00
parent 92ebd8aefa
commit 4a56f7b360
10 changed files with 52 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -428,6 +428,13 @@ class FunctionType extends AbstractFunctionType {
return false;
}
static final void Function(Object, Object) _logIgnoredCast =
JS('', '''(() => $_ignoreMemo((actual, expected) => {
console.warn('Ignoring cast fail from ' + $typeName(actual) +
' to ' + $typeName(expected));
return null;
}))()''');
@JSExportName('as')
as_T(obj, [bool typeError]) {
if (obj == null) return obj;
@ -439,8 +446,7 @@ class FunctionType extends AbstractFunctionType {
var result = isSubtype(actual, this);
if (result == true) return obj;
if (result == null && JS('bool', 'dart.__ignoreWhitelistedErrors')) {
JS('', "console.warn(#)",
'Ignoring cast fail from ${typeName(actual)} to ${typeName(this)}');
_logIgnoredCast(actual, this);
return obj;
}
}