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

Side by Side Diff: pkg/compiler/lib/src/warnings.dart

Issue 709603003: Add compile-time errors for enums. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 const DONT_KNOW_HOW_TO_FIX = ""; 7 const DONT_KNOW_HOW_TO_FIX = "";
8 8
9 /** 9 /**
10 * The messages in this file should meet the following guide lines: 10 * The messages in this file should meet the following guide lines:
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 examples: const [""" 790 examples: const ["""
791 class C extends Object with String {} 791 class C extends Object with String {}
792 792
793 main() => new C(); 793 main() => new C();
794 """, """ 794 """, """
795 typedef C = Object with String; 795 typedef C = Object with String;
796 796
797 main() => new C(); 797 main() => new C();
798 """]); 798 """]);
799 799
800 static const MessageKind CANNOT_EXTEND_ENUM = const MessageKind(
801 "Class '#{className}' can't extend the type '#{enumType}' because "
802 "it is declared by an enum.",
803 options: const ['--enable-enum'],
804 howToFix: "Try making '#{enumType}' a normal class or removing the "
805 "'extends' clause.",
806 examples: const ["""
807 enum Enum {}
808 class A extends Enum {}
809 main() => new A();"""]);
810
811 static const MessageKind CANNOT_IMPLEMENT_ENUM = const MessageKind(
812 "Class '#{className}' can't implement the type '#{enumType}' "
813 "because it is declared by an enum.",
814 options: const ['--enable-enum'],
815 howToFix: "Try making '#{enumType}' a normal class or removing the "
816 "type from the 'implements' clause.",
817 examples: const ["""
818 enum Enum {}
819 class A implements Enum {}
820 main() => new A();"""]);
821
822 static const MessageKind CANNOT_MIXIN_ENUM = const MessageKind(
823 "Class '#{className}' can't mixin the type '#{enumType}' because it "
824 "is declared by an enum.",
825 options: const ['--enable-enum'],
826 howToFix: "Try making '#{enumType}' a normal class or removing the "
827 "type from the 'with' clause.",
828 examples: const ["""
829 enum Enum {}
830 class A extends Object with Enum {}
831 main() => new A();"""]);
832
833 static const MessageKind CANNOT_INSTANTIATE_ENUM = const MessageKind(
834 "Enum type '#{enumName}' cannot be instantiated.",
835 options: const ['--enable-enum'],
836 howToFix: "Try making '#{enumType}' a normal class or use an enum "
837 "constant.",
838 examples: const ["""
839 enum Enum {}
840 main() => new Enum(0, '');""", """
841 enum Enum {}
842 main() => const Enum(0, '');"""]);
843
800 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( 844 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind(
801 "'#{type}' can not be both extended and implemented."); 845 "'#{type}' can not be both extended and implemented.");
802 846
803 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind( 847 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind(
804 "'#{type}' must not occur more than once " 848 "'#{type}' must not occur more than once "
805 "in the implements clause."); 849 "in the implements clause.");
806 850
807 static const MessageKind MULTI_INHERITANCE = const MessageKind( 851 static const MessageKind MULTI_INHERITANCE = const MessageKind(
808 "Dart2js does not currently support inheritance of the same class with " 852 "Dart2js does not currently support inheritance of the same class with "
809 "different type arguments: Both #{firstType} and #{secondType} are " 853 "different type arguments: Both #{firstType} and #{secondType} are "
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 static String convertToString(value) { 2286 static String convertToString(value) {
2243 if (value is ErrorToken) { 2287 if (value is ErrorToken) {
2244 // Shouldn't happen. 2288 // Shouldn't happen.
2245 return value.assertionMessage; 2289 return value.assertionMessage;
2246 } else if (value is Token) { 2290 } else if (value is Token) {
2247 value = value.value; 2291 value = value.value;
2248 } 2292 }
2249 return '$value'; 2293 return '$value';
2250 } 2294 }
2251 } 2295 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698