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

Side by Side Diff: pkg/analyzer/lib/src/error/codes.dart

Issue 2482573002: fix #27764, split STATIC_TYPE_ERROR into more detailed ones (Closed)
Patch Set: format Created 4 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
« no previous file with comments | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analyzer.src.error.codes; 5 library analyzer.src.error.codes;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 8
9 export 'package:analyzer/src/analysis_options/error/option_codes.dart'; 9 export 'package:analyzer/src/analysis_options/error/option_codes.dart';
10 export 'package:analyzer/src/dart/error/hint_codes.dart'; 10 export 'package:analyzer/src/dart/error/hint_codes.dart';
(...skipping 4633 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 /** 4644 /**
4645 * This class has Strong Mode specific error codes. 4645 * This class has Strong Mode specific error codes.
4646 * 4646 *
4647 * These error codes tend to use the same message across different severity 4647 * These error codes tend to use the same message across different severity
4648 * levels, so they are grouped for clarity. 4648 * levels, so they are grouped for clarity.
4649 * 4649 *
4650 * All of these error codes also use the "STRONG_MODE_" prefix in their name. 4650 * All of these error codes also use the "STRONG_MODE_" prefix in their name.
4651 */ 4651 */
4652 class StrongModeCode extends ErrorCode { 4652 class StrongModeCode extends ErrorCode {
4653 static const String _implicitCastMessage = 4653 static const String _implicitCastMessage =
4654 "Unsound implicit cast from '{0}' to '{1}'."; 4654 "Unsafe implicit cast from '{0}' to '{1}'. "
4655 "This usually indicates that type information was lost and resulted in "
4656 "'dynamic' and/or a place that will have a failure at runtime.";
4655 4657
4656 static const String _implicitCastCorrection = 4658 static const String _implicitCastCorrection =
4657 "Try adding an explicit cast to '{1}'."; 4659 "Try adding an explicit cast to '{1}' or improving the type of '{0}'.";
4658 4660
4659 static const String _invalidOverrideMessage = 4661 static const String _invalidOverrideMessage =
4660 "The type of '{0}.{1}' ('{2}') isn't a subtype of '{3}.{1}' ('{4}')."; 4662 "The type of '{0}.{1}' ('{2}') isn't a subtype of '{3}.{1}' ('{4}').";
4661 4663
4662 /** 4664 /**
4663 * This is appended to the end of an error message about implicit dynamic. 4665 * This is appended to the end of an error message about implicit dynamic.
4664 * 4666 *
4665 * The idea is to make sure the user is aware that this error message is the 4667 * The idea is to make sure the user is aware that this error message is the
4666 * result of turning on a particular option, and they are free to turn it 4668 * result of turning on a particular option, and they are free to turn it
4667 * back off. 4669 * back off.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4718 4720
4719 static const StrongModeCode INFERRED_TYPE_LITERAL = const StrongModeCode( 4721 static const StrongModeCode INFERRED_TYPE_LITERAL = const StrongModeCode(
4720 ErrorType.HINT, 'INFERRED_TYPE_LITERAL', _inferredTypeMessage); 4722 ErrorType.HINT, 'INFERRED_TYPE_LITERAL', _inferredTypeMessage);
4721 4723
4722 static const StrongModeCode INFERRED_TYPE_ALLOCATION = const StrongModeCode( 4724 static const StrongModeCode INFERRED_TYPE_ALLOCATION = const StrongModeCode(
4723 ErrorType.HINT, 'INFERRED_TYPE_ALLOCATION', _inferredTypeMessage); 4725 ErrorType.HINT, 'INFERRED_TYPE_ALLOCATION', _inferredTypeMessage);
4724 4726
4725 static const StrongModeCode INFERRED_TYPE_CLOSURE = const StrongModeCode( 4727 static const StrongModeCode INFERRED_TYPE_CLOSURE = const StrongModeCode(
4726 ErrorType.HINT, 'INFERRED_TYPE_CLOSURE', _inferredTypeMessage); 4728 ErrorType.HINT, 'INFERRED_TYPE_CLOSURE', _inferredTypeMessage);
4727 4729
4728 static const StrongModeCode STATIC_TYPE_ERROR = const StrongModeCode( 4730 static const StrongModeCode INVALID_CAST_LITERAL = const StrongModeCode(
4729 ErrorType.COMPILE_TIME_ERROR, 4731 ErrorType.COMPILE_TIME_ERROR,
4730 'STATIC_TYPE_ERROR', 4732 'INVALID_CAST_LITERAL',
4731 "Type check failed: '{0}' ('{1}') isn't of type '{2}'."); 4733 "The literal '{0}' with type '{1}' isn't of expected type '{2}'.");
4734
4735 static const StrongModeCode INVALID_CAST_LITERAL_LIST = const StrongModeCode(
4736 ErrorType.COMPILE_TIME_ERROR,
4737 'INVALID_CAST_LITERAL_LIST',
4738 "The list literal type '{0}' isn't of expected type '{1}'. The list's "
4739 "type can be changed with an explicit generic type argument or by "
4740 "changing the element types.");
4741
4742 static const StrongModeCode INVALID_CAST_LITERAL_MAP = const StrongModeCode(
4743 ErrorType.COMPILE_TIME_ERROR,
4744 'INVALID_CAST_LITERAL_MAP',
4745 "The map literal type '{0}' isn't of expected type '{1}'. The maps's "
4746 "type can be changed with an explicit generic type arguments or by "
4747 "changing the key and value types.");
4748
4749 static const StrongModeCode INVALID_CAST_FUNCTION_EXPR = const StrongModeCode(
4750 ErrorType.COMPILE_TIME_ERROR,
4751 'INVALID_CAST_FUNCTION_EXPR',
4752 "The function expression type '{0}' isn't of type '{1}'. "
4753 "This means its parameter or return type does not match what is "
4754 "expected. Consider changing parameter type(s) or the returned type(s).");
4755
4756 static const StrongModeCode INVALID_CAST_NEW_EXPR = const StrongModeCode(
4757 ErrorType.COMPILE_TIME_ERROR,
4758 'INVALID_CAST_NEW_EXPR',
4759 "The constructor returns type '{0}' that isn't of expected type '{1}'.");
4760
4761 static const StrongModeCode INVALID_CAST_METHOD = const StrongModeCode(
4762 ErrorType.COMPILE_TIME_ERROR,
4763 'INVALID_CAST_METHOD',
4764 "The method tear-off '{0}' has type '{1}' that isn't of expected type "
4765 "'{2}'. This means its parameter or return type does not match what is "
4766 "expected.");
4767
4768 static const StrongModeCode INVALID_CAST_FUNCTION = const StrongModeCode(
4769 ErrorType.COMPILE_TIME_ERROR,
4770 'INVALID_CAST_FUNCTION',
4771 "The function '{0}' has type '{1}' that isn't of expected type "
4772 "'{2}'. This means its parameter or return type does not match what is "
4773 "expected.");
4732 4774
4733 static const StrongModeCode INVALID_SUPER_INVOCATION = const StrongModeCode( 4775 static const StrongModeCode INVALID_SUPER_INVOCATION = const StrongModeCode(
4734 ErrorType.COMPILE_TIME_ERROR, 4776 ErrorType.COMPILE_TIME_ERROR,
4735 'INVALID_SUPER_INVOCATION', 4777 'INVALID_SUPER_INVOCATION',
4736 "super call must be last in an initializer " 4778 "super call must be last in an initializer "
4737 "list (see https://goo.gl/EY6hDP): '{0}'."); 4779 "list (see https://goo.gl/EY6hDP): '{0}'.");
4738 4780
4739 static const StrongModeCode NON_GROUND_TYPE_CHECK_INFO = const StrongModeCode( 4781 static const StrongModeCode NON_GROUND_TYPE_CHECK_INFO = const StrongModeCode(
4740 ErrorType.HINT, 4782 ErrorType.HINT,
4741 'NON_GROUND_TYPE_CHECK_INFO', 4783 'NON_GROUND_TYPE_CHECK_INFO',
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4845 * created from the optional [correction] template. 4887 * created from the optional [correction] template.
4846 */ 4888 */
4847 const StrongModeCode(ErrorType type, String name, String message, 4889 const StrongModeCode(ErrorType type, String name, String message,
4848 [String correction]) 4890 [String correction])
4849 : type = type, 4891 : type = type,
4850 super('STRONG_MODE_$name', message, correction); 4892 super('STRONG_MODE_$name', message, correction);
4851 4893
4852 @override 4894 @override
4853 ErrorSeverity get errorSeverity => type.severity; 4895 ErrorSeverity get errorSeverity => type.severity;
4854 } 4896 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698