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

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_helper.dart

Issue 2639733004: dart2js: Make .runtimeType work for tear-off closures (Closed)
Patch Set: line-wrap Created 3 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/js_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 638a31c70751ae5f79a981cf8b84aed18a045480..86e80d81b6ddbed5229a0da8d4540ac24cdd27c3 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -3409,8 +3409,8 @@ class CastErrorImplementation extends Error implements CastError {
* Normal cast error caused by a failed type cast.
*/
CastErrorImplementation(Object actualType, Object expectedType)
- : message = "CastError: Casting value of type $actualType to"
- " incompatible type $expectedType";
+ : message = "CastError: Casting value of type '$actualType' to"
+ " incompatible type '$expectedType'";
String toString() => message;
}
@@ -3514,7 +3514,7 @@ class RuntimeFunctionType extends RuntimeType {
/// returns true if [this] is a supertype of [expression].
@NoInline() @NoSideEffects()
bool _isTest(expression) {
- var functionTypeObject = _extractFunctionTypeObjectFrom(expression);
+ var functionTypeObject = extractFunctionTypeObjectFrom(expression);
return functionTypeObject == null
? false
: isFunctionSubtype(functionTypeObject, toRti());
@@ -3542,12 +3542,12 @@ class RuntimeFunctionType extends RuntimeType {
if (expression == null) return null;
if (_isTest(expression)) return expression;
- var self = new FunctionTypeInfoDecoderRing(toRti()).toString();
+ var self = runtimeTypeToString(toRti());
if (isCast) {
- var functionTypeObject = _extractFunctionTypeObjectFrom(expression);
+ var functionTypeObject = extractFunctionTypeObjectFrom(expression);
var pretty;
if (functionTypeObject != null) {
- pretty = new FunctionTypeInfoDecoderRing(functionTypeObject).toString();
+ pretty = runtimeTypeToString(functionTypeObject);
} else {
pretty = Primitives.objectTypeName(expression);
}
@@ -3558,14 +3558,6 @@ class RuntimeFunctionType extends RuntimeType {
}
}
- _extractFunctionTypeObjectFrom(o) {
- var interceptor = getInterceptor(o);
- var signatureName = JS_GET_NAME(JsGetName.SIGNATURE_NAME);
- return JS('bool', '# in #', signatureName, interceptor)
- ? JS('', '#[#]()', interceptor, JS_GET_NAME(JsGetName.SIGNATURE_NAME))
- : null;
- }
-
toRti() {
var result = createDartFunctionTypeRti();
if (isVoid) {
@@ -3657,6 +3649,14 @@ class RuntimeFunctionType extends RuntimeType {
}
}
+extractFunctionTypeObjectFrom(o) {
+ var interceptor = getInterceptor(o);
+ var signatureName = JS_GET_NAME(JsGetName.SIGNATURE_NAME);
+ return JS('bool', '# in #', signatureName, interceptor)
+ ? JS('', '#[#]()', interceptor, signatureName)
+ : null;
+}
+
RuntimeFunctionType buildFunctionType(returnType,
parameterTypes,
optionalParameterTypes) {
@@ -3816,58 +3816,8 @@ class FunctionTypeInfoDecoderRing {
return const DynamicRuntimeType();
}
- String _convert(type) {
- String result = runtimeTypeToString(type);
- if (result != null) return result;
- // Currently the [runtimeTypeToString] method doesn't handle function rtis.
- if (JS('bool', '"func" in #', type)) {
- return new FunctionTypeInfoDecoderRing(type).toString();
- } else {
- throw 'bad type';
- }
- }
-
String toString() {
- if (_cachedToString != null) return _cachedToString;
- var s = "(";
- var sep = '';
- if (_hasArguments) {
- for (var argument in _arguments) {
- s += sep;
- s += _convert(argument);
- sep = ', ';
- }
- }
- if (_hasOptionalArguments) {
- s += '$sep[';
- sep = '';
- for (var argument in _optionalArguments) {
- s += sep;
- s += _convert(argument);
- sep = ', ';
- }
- s += ']';
- }
- if (_hasNamedArguments) {
- s += '$sep{';
- sep = '';
- for (var name in extractKeys(_namedArguments)) {
- s += sep;
- s += '$name: ';
- s += _convert(JS('', '#[#]', _namedArguments, name));
- sep = ', ';
- }
- s += '}';
- }
- s += ') -> ';
- if (_isVoid) {
- s += 'void';
- } else if (_hasReturnType) {
- s += _convert(_returnType);
- } else {
- s += 'dynamic';
- }
- return _cachedToString = "$s";
+ return _cachedToString ??= runtimeTypeToString(_typeData);
}
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698