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

Side by Side Diff: pkg/compiler/lib/src/diagnostics/messages.dart

Issue 1423623008: Improve messages and static use for super/this-calls. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 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
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 5
6 /** 6 /**
7 * The messages in this file should meet the following guide lines: 7 * The messages in this file should meet the following guide lines:
8 * 8 *
9 * 1. The message should be a complete sentence starting with an uppercase 9 * 1. The message should be a complete sentence starting with an uppercase
10 * letter, and ending with a period. 10 * letter, and ending with a period.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE, 100 AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE,
101 BAD_INPUT_CHARACTER, 101 BAD_INPUT_CHARACTER,
102 BEFORE_TOP_LEVEL, 102 BEFORE_TOP_LEVEL,
103 BINARY_OPERATOR_BAD_ARITY, 103 BINARY_OPERATOR_BAD_ARITY,
104 BODY_EXPECTED, 104 BODY_EXPECTED,
105 CALL_NOT_SUPPORTED_ON_NATIVE_CLASS, 105 CALL_NOT_SUPPORTED_ON_NATIVE_CLASS,
106 CANNOT_EXTEND, 106 CANNOT_EXTEND,
107 CANNOT_EXTEND_ENUM, 107 CANNOT_EXTEND_ENUM,
108 CANNOT_EXTEND_MALFORMED, 108 CANNOT_EXTEND_MALFORMED,
109 CANNOT_FIND_CONSTRUCTOR, 109 CANNOT_FIND_CONSTRUCTOR,
110 CANNOT_FIND_UNNAMED_CONSTRUCTOR,
110 CANNOT_IMPLEMENT, 111 CANNOT_IMPLEMENT,
111 CANNOT_IMPLEMENT_ENUM, 112 CANNOT_IMPLEMENT_ENUM,
112 CANNOT_IMPLEMENT_MALFORMED, 113 CANNOT_IMPLEMENT_MALFORMED,
113 CANNOT_INSTANTIATE_ENUM, 114 CANNOT_INSTANTIATE_ENUM,
114 CANNOT_INSTANTIATE_TYPE_VARIABLE, 115 CANNOT_INSTANTIATE_TYPE_VARIABLE,
115 CANNOT_INSTANTIATE_TYPEDEF, 116 CANNOT_INSTANTIATE_TYPEDEF,
116 CANNOT_MIXIN, 117 CANNOT_MIXIN,
117 CANNOT_MIXIN_ENUM, 118 CANNOT_MIXIN_ENUM,
118 CANNOT_MIXIN_MALFORMED, 119 CANNOT_MIXIN_MALFORMED,
119 CANNOT_OVERRIDE_FIELD_WITH_METHOD, 120 CANNOT_OVERRIDE_FIELD_WITH_METHOD,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 REFERENCE_IN_INITIALIZATION, 397 REFERENCE_IN_INITIALIZATION,
397 REQUIRED_PARAMETER_WITH_DEFAULT, 398 REQUIRED_PARAMETER_WITH_DEFAULT,
398 RETURN_IN_GENERATOR, 399 RETURN_IN_GENERATOR,
399 RETURN_NOTHING, 400 RETURN_NOTHING,
400 RETURN_VALUE_IN_VOID, 401 RETURN_VALUE_IN_VOID,
401 SETTER_MISMATCH, 402 SETTER_MISMATCH,
402 SETTER_NOT_FOUND, 403 SETTER_NOT_FOUND,
403 SETTER_NOT_FOUND_IN_SUPER, 404 SETTER_NOT_FOUND_IN_SUPER,
404 STATIC_FUNCTION_BLOAT, 405 STATIC_FUNCTION_BLOAT,
405 STRING_EXPECTED, 406 STRING_EXPECTED,
407 SUPER_CALL_TO_FACTORY,
406 SUPER_INITIALIZER_IN_OBJECT, 408 SUPER_INITIALIZER_IN_OBJECT,
407 SWITCH_CASE_FORBIDDEN, 409 SWITCH_CASE_FORBIDDEN,
408 SWITCH_CASE_TYPES_NOT_EQUAL, 410 SWITCH_CASE_TYPES_NOT_EQUAL,
409 SWITCH_CASE_TYPES_NOT_EQUAL_CASE, 411 SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
410 SWITCH_CASE_VALUE_OVERRIDES_EQUALS, 412 SWITCH_CASE_VALUE_OVERRIDES_EQUALS,
411 TERNARY_OPERATOR_BAD_ARITY, 413 TERNARY_OPERATOR_BAD_ARITY,
414 THIS_CALL_TO_FACTORY,
412 THIS_IS_THE_DECLARATION, 415 THIS_IS_THE_DECLARATION,
413 THIS_IS_THE_METHOD, 416 THIS_IS_THE_METHOD,
414 THIS_IS_THE_PART_OF_TAG, 417 THIS_IS_THE_PART_OF_TAG,
415 THIS_PROPERTY, 418 THIS_PROPERTY,
416 THROW_WITHOUT_EXPRESSION, 419 THROW_WITHOUT_EXPRESSION,
417 TOP_LEVEL_VARIABLE_DECLARED_STATIC, 420 TOP_LEVEL_VARIABLE_DECLARED_STATIC,
418 TYPE_ARGUMENT_COUNT_MISMATCH, 421 TYPE_ARGUMENT_COUNT_MISMATCH,
419 TYPE_VARIABLE_IN_CONSTANT, 422 TYPE_VARIABLE_IN_CONSTANT,
420 TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 423 TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
421 TYPEDEF_FORMAL_WITH_DEFAULT, 424 TYPEDEF_FORMAL_WITH_DEFAULT,
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 MessageKind.NOT_A_PREFIX: 892 MessageKind.NOT_A_PREFIX:
890 const MessageTemplate(MessageKind.NOT_A_PREFIX, 893 const MessageTemplate(MessageKind.NOT_A_PREFIX,
891 "'#{node}' is not a prefix."), 894 "'#{node}' is not a prefix."),
892 895
893 MessageKind.PREFIX_AS_EXPRESSION: 896 MessageKind.PREFIX_AS_EXPRESSION:
894 const MessageTemplate(MessageKind.PREFIX_AS_EXPRESSION, 897 const MessageTemplate(MessageKind.PREFIX_AS_EXPRESSION,
895 "Library prefix '#{prefix}' is not a valid expression."), 898 "Library prefix '#{prefix}' is not a valid expression."),
896 899
897 MessageKind.CANNOT_FIND_CONSTRUCTOR: 900 MessageKind.CANNOT_FIND_CONSTRUCTOR:
898 const MessageTemplate(MessageKind.CANNOT_FIND_CONSTRUCTOR, 901 const MessageTemplate(MessageKind.CANNOT_FIND_CONSTRUCTOR,
899 "Cannot find constructor '#{constructorName}'."), 902 "Cannot find constructor '#{constructorName}' in class "
903 "'#{className}'."),
904
905 MessageKind.CANNOT_FIND_UNNAMED_CONSTRUCTOR:
906 const MessageTemplate(MessageKind.CANNOT_FIND_UNNAMED_CONSTRUCTOR,
907 "Cannot find unnamed constructor in class "
908 "'#{className}'."),
900 909
901 MessageKind.CYCLIC_CLASS_HIERARCHY: 910 MessageKind.CYCLIC_CLASS_HIERARCHY:
902 const MessageTemplate(MessageKind.CYCLIC_CLASS_HIERARCHY, 911 const MessageTemplate(MessageKind.CYCLIC_CLASS_HIERARCHY,
903 "'#{className}' creates a cycle in the class hierarchy."), 912 "'#{className}' creates a cycle in the class hierarchy."),
904 913
905 MessageKind.CYCLIC_REDIRECTING_FACTORY: 914 MessageKind.CYCLIC_REDIRECTING_FACTORY:
906 const MessageTemplate(MessageKind.CYCLIC_REDIRECTING_FACTORY, 915 const MessageTemplate(MessageKind.CYCLIC_REDIRECTING_FACTORY,
907 'Redirecting factory leads to a cyclic redirection.'), 916 'Redirecting factory leads to a cyclic redirection.'),
908 917
909 MessageKind.INVALID_RECEIVER_IN_INITIALIZER: 918 MessageKind.INVALID_RECEIVER_IN_INITIALIZER:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 "Redirecting constructor cannot have other initializers."), 980 "Redirecting constructor cannot have other initializers."),
972 981
973 MessageKind.SUPER_INITIALIZER_IN_OBJECT: 982 MessageKind.SUPER_INITIALIZER_IN_OBJECT:
974 const MessageTemplate(MessageKind.SUPER_INITIALIZER_IN_OBJECT, 983 const MessageTemplate(MessageKind.SUPER_INITIALIZER_IN_OBJECT,
975 "'Object' cannot have a super initializer."), 984 "'Object' cannot have a super initializer."),
976 985
977 MessageKind.DUPLICATE_SUPER_INITIALIZER: 986 MessageKind.DUPLICATE_SUPER_INITIALIZER:
978 const MessageTemplate(MessageKind.DUPLICATE_SUPER_INITIALIZER, 987 const MessageTemplate(MessageKind.DUPLICATE_SUPER_INITIALIZER,
979 "Cannot have more than one super initializer."), 988 "Cannot have more than one super initializer."),
980 989
990 MessageKind.SUPER_CALL_TO_FACTORY:
991 const MessageTemplate(MessageKind.SUPER_CALL_TO_FACTORY,
992 "The target of the superinitializer must be a generative "
993 "constructor.",
994 howToFix: "Try calling another constructor on the superclass.",
995 examples: const ["""
996 class Super {
997 factory Super() => null;
998 }
999 class Class extends Super {}
1000 main() => new Class();
1001 """, """
1002 class Super {
1003 factory Super() => null;
1004 }
1005 class Class extends Super {
1006 Class();
1007 }
1008 main() => new Class();
1009 """, """
1010 class Super {
1011 factory Super() => null;
1012 }
1013 class Class extends Super {
1014 Class() : super();
1015 }
1016 main() => new Class();
1017 """, """
1018 class Super {
1019 factory Super.foo() => null;
1020 }
1021 class Class extends Super {
1022 Class() : super.foo();
1023 }
1024 main() => new Class();
1025 """]),
1026
1027 MessageKind.THIS_CALL_TO_FACTORY:
1028 const MessageTemplate(MessageKind.THIS_CALL_TO_FACTORY,
1029 "The target of the redirection clause must be a generative "
1030 "constructor",
1031 howToFix: "Try redirecting to another constructor.",
1032 examples: const ["""
1033 class Class {
1034 factory Class() => null;
1035 Class.foo() : this();
1036 }
1037 main() => new Class.foo();
1038 """, """
1039 class Class {
1040 factory Class.foo() => null;
1041 Class() : this.foo();
1042 }
1043 main() => new Class();
1044 """]),
1045
981 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS: 1046 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS:
982 const MessageTemplate(MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, 1047 const MessageTemplate(MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS,
983 "Arguments do not match the expected parameters of constructor " 1048 "Arguments do not match the expected parameters of constructor "
984 "'#{constructorName}'."), 1049 "'#{constructorName}'."),
985 1050
986 MessageKind.NO_MATCHING_CONSTRUCTOR: 1051 MessageKind.NO_MATCHING_CONSTRUCTOR:
987 const MessageTemplate(MessageKind.NO_MATCHING_CONSTRUCTOR, 1052 const MessageTemplate(MessageKind.NO_MATCHING_CONSTRUCTOR,
988 "'super' call arguments and constructor parameters do not match."), 1053 "'super' call arguments and constructor parameters do not match."),
989 1054
990 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: 1055 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT:
(...skipping 2563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 static String convertToString(value) { 3619 static String convertToString(value) {
3555 if (value is ErrorToken) { 3620 if (value is ErrorToken) {
3556 // Shouldn't happen. 3621 // Shouldn't happen.
3557 return value.assertionMessage; 3622 return value.assertionMessage;
3558 } else if (value is Token) { 3623 } else if (value is Token) {
3559 value = value.value; 3624 value = value.value;
3560 } 3625 }
3561 return '$value'; 3626 return '$value';
3562 } 3627 }
3563 } 3628 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/resolution/class_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698