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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 54983007: Make test of malformed types a dynamic type error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 1 month 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/js_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index cdceeec2d889fb996262dd56f876d06fcf52b333..a32c4ee3c71d7e9a10e2a368c5533bbb6972d3c5 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -35,6 +35,17 @@ class CheckedModeHelper {
}
}
+class MalformedCheckedModeHelper extends CheckedModeHelper {
+ const MalformedCheckedModeHelper(String name) : super(name);
+
+ void generateAdditionalArguments(SsaCodeGenerator codegen,
+ HTypeConversion node,
+ List<jsAst.Expression> arguments) {
+ ErroneousElement element = node.typeExpression.element;
+ arguments.add(js.string(element.message));
+ }
+}
+
class PropertyCheckedModeHelper extends CheckedModeHelper {
const PropertyCheckedModeHelper(String name) : super(name);
@@ -338,6 +349,7 @@ class JavaScriptBackend extends Backend {
/// All the checked mode helpers.
static const checkedModeHelpers = const [
+ const MalformedCheckedModeHelper('checkMalformedType'),
const CheckedModeHelper('voidTypeCheck'),
const CheckedModeHelper('stringTypeCast'),
const CheckedModeHelper('stringTypeCheck'),
@@ -988,6 +1000,9 @@ class JavaScriptBackend extends Backend {
}
}
bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
+ if (type.kind == TypeKind.MALFORMED_TYPE) {
+ enqueueInResolution(getThrowTypeError(), elements);
+ }
if (!type.treatAsRaw || type.containsTypeVariables) {
enqueueInResolution(getSetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeInfo(), elements);
@@ -1324,6 +1339,11 @@ class JavaScriptBackend extends Backend {
{bool typeCast,
bool nativeCheckOnly}) {
assert(type.kind != TypeKind.TYPEDEF);
+ if (type.kind == TypeKind.MALFORMED_TYPE) {
+ // 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;
bool nativeCheck = nativeCheckOnly ||
emitter.nativeEmitter.requiresNativeIsCheck(element);

Powered by Google App Engine
This is Rietveld 408576698