Chromium Code Reviews| Index: pkg/compiler/lib/src/js_backend/backend.dart |
| diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart |
| index 8b81c7af61283c20929f807a17b195eea27b74db..a1b508bcd8262022c7143769d22966770cbaff3d 100644 |
| --- a/pkg/compiler/lib/src/js_backend/backend.dart |
| +++ b/pkg/compiler/lib/src/js_backend/backend.dart |
| @@ -786,6 +786,12 @@ class JavaScriptBackend extends Backend { |
| @override |
| bool isJsInterop(Element element) => nativeData.isJsInterop(element); |
| + /// Returns `true` if [element] is a JsInterop class. |
| + bool isJsInteropClass(ClassElement element) => isJsInterop(element); |
| + |
| + /// Returns `true` if [element] is a JsInterop method. |
| + bool isJsInteropMethod(MethodElement element) => isJsInterop(element); |
| + |
| /// Whether [element] corresponds to a native JavaScript construct either |
| /// through the native mechanism (`@Native(...)` or the `native` pseudo |
| /// keyword) which is only allowed for internal libraries or via the typed |
| @@ -1623,13 +1629,26 @@ class JavaScriptBackend extends Backend { |
| String getCheckedModeHelperNameInternal(ResolutionDartType type, |
| {bool typeCast, bool nativeCheckOnly}) { |
| - assert(type.kind != ResolutionTypeKind.TYPEDEF); |
| + assert(!type.isDynamic); |
| + assert(!type.isTypedef); |
| if (type.isMalformed) { |
| // The same error is thrown for type test and type cast of a malformed |
| // type so we only need one check method. |
| return 'checkMalformedType'; |
| - } |
| - Element element = type.element; |
| + } else if (type.isVoid) { |
|
Siggi Cherem (dart-lang)
2017/01/20 17:00:15
while we are here, we could clean up this function
Johnni Winther
2017/01/23 10:00:09
I like it; it's much more readable. I've merge it
|
| + assert(!typeCast); // Cannot cast to void. |
| + if (nativeCheckOnly) return null; |
| + return 'voidTypeCheck'; |
| + } else if (type.isTypeVariable) { |
| + return typeCast |
| + ? 'subtypeOfRuntimeTypeCast' |
| + : 'assertSubtypeOfRuntimeType'; |
| + } else if (type.isFunctionType) { |
| + return null; |
| + } |
| + assert(invariant(NO_LOCATION_SPANNABLE, type.isInterfaceType, |
| + message: "Unexpected type: $type (${type.kind})")); |
| + ClassElement element = type.element; |
| bool nativeCheck = |
| nativeCheckOnly || emitter.nativeEmitter.requiresNativeIsCheck(element); |
| @@ -1638,11 +1657,7 @@ class JavaScriptBackend extends Backend { |
| // that it can be optimized by standard interceptor optimizations. |
| nativeCheck = true; |
| - if (type.isVoid) { |
| - assert(!typeCast); // Cannot cast to void. |
| - if (nativeCheckOnly) return null; |
| - return 'voidTypeCheck'; |
| - } else if (element == helpers.jsStringClass || |
| + if (element == helpers.jsStringClass || |
| element == commonElements.stringClass) { |
| if (nativeCheckOnly) return null; |
| return typeCast ? 'stringTypeCast' : 'stringTypeCheck'; |
| @@ -1700,12 +1715,6 @@ class JavaScriptBackend extends Backend { |
| } else { |
| if (type.isInterfaceType && !type.treatAsRaw) { |
| return typeCast ? 'subtypeCast' : 'assertSubtype'; |
| - } else if (type.isTypeVariable) { |
| - return typeCast |
| - ? 'subtypeOfRuntimeTypeCast' |
| - : 'assertSubtypeOfRuntimeType'; |
| - } else if (type.isFunctionType) { |
| - return null; |
| } else { |
| if (nativeCheck) { |
| // TODO(karlklose): can we get rid of this branch when we use |
| @@ -3062,6 +3071,7 @@ class JavaScriptImpactTransformer extends ImpactTransformer { |
| void onIsCheckForCodegen( |
| ResolutionDartType type, TransformedWorldImpact transformed) { |
| + if (type.isDynamic) return; |
| type = type.unaliased; |
| registerBackendImpact(transformed, impacts.typeCheck); |