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

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

Issue 88433002: Emit a compile-time error when using type literals in case-expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/typechecker.dart
diff --git a/sdk/lib/_internal/compiler/implementation/typechecker.dart b/sdk/lib/_internal/compiler/implementation/typechecker.dart
index 965d95ff54392f7a13e8396fcf5e667a9da9d4e8..f5eccfd324f77b4134c447d7e01c2ae517c96231 100644
--- a/sdk/lib/_internal/compiler/implementation/typechecker.dart
+++ b/sdk/lib/_internal/compiler/implementation/typechecker.dart
@@ -1508,6 +1508,7 @@ class TypeCheckerVisitor extends Visitor<DartType> {
ClassElement cls = type.element;
if (cls == compiler.doubleClass) return true;
if (cls == compiler.intClass || cls == compiler.stringClass) return false;
+ if (cls == compiler.typeClass) return true;
Johnni Winther 2013/11/26 14:53:48 Add a TODO that we in general need to look at the
Element equals = cls.lookupMember('==');
return equals.getEnclosingClass() != compiler.objectClass;
}
@@ -1562,7 +1563,8 @@ class TypeCheckerVisitor extends Visitor<DartType> {
if (firstCaseType != null &&
invalidSwitchExpressionType(firstCase, firstCaseType)) {
compiler.reportError(firstCase.expression,
- MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS);
+ MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS,
+ {'type': firstCaseType});
}
return StatementType.NOT_RETURNING;
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698