mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 18:31:32 +00:00
Remove errors for raw types in is
or as
expressions.
This brings the errors in line with the exceptions described in the spec: https://github.com/dart-lang/language/blob/master/resources/type-system/strict-raw-types.md#conditions-for-a-raw-type-hint Change-Id: I045237d937579d4390d3e676dc5e12346b90b480 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116381 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
2cc0c4fcc0
commit
80040e5cfe
|
@ -382,8 +382,6 @@ const List<ErrorCode> errorCodeValues = const [
|
|||
HintCode.SDK_VERSION_UI_AS_CODE,
|
||||
HintCode.SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT,
|
||||
HintCode.STRICT_RAW_TYPE,
|
||||
HintCode.STRICT_RAW_TYPE_IN_AS,
|
||||
HintCode.STRICT_RAW_TYPE_IN_IS,
|
||||
HintCode.SUBTYPE_OF_SEALED_CLASS,
|
||||
HintCode.TYPE_CHECK_IS_NOT_NULL,
|
||||
HintCode.TYPE_CHECK_IS_NULL,
|
||||
|
|
|
@ -844,24 +844,6 @@ class HintCode extends AnalyzerErrorCode {
|
|||
"The generic type '{0}' should have explicit type arguments but doesn't.",
|
||||
correction: "Use explicit type arguments for '{0}'.");
|
||||
|
||||
/**
|
||||
* When "strict-raw-types" is enabled, raw types must be inferred via the
|
||||
* context type, or have type arguments.
|
||||
*/
|
||||
static const HintCode STRICT_RAW_TYPE_IN_AS = HintCode(
|
||||
'STRICT_RAW_TYPE_IN_AS',
|
||||
"The generic type '{0}' should have explicit type arguments but doesn't.",
|
||||
correction: "Use explicit type arguments for '{0}'.");
|
||||
|
||||
/**
|
||||
* When "strict-raw-types" is enabled, raw types must be inferred via the
|
||||
* context type, or have type arguments.
|
||||
*/
|
||||
static const HintCode STRICT_RAW_TYPE_IN_IS = HintCode(
|
||||
'STRICT_RAW_TYPE_IN_IS',
|
||||
"The generic type '{0}' should have explicit type arguments but doesn't.",
|
||||
correction: "Use explicit type arguments for '{0}'.");
|
||||
|
||||
/**
|
||||
* This hint is generated anywhere where a `@sealed` class or mixin is used as
|
||||
* a super-type of a class.
|
||||
|
|
|
@ -194,12 +194,9 @@ class TypeArgumentsVerifier {
|
|||
if (_isMissingTypeArguments(
|
||||
node, node.type, node.name.staticElement, null)) {
|
||||
AstNode unwrappedParent = parentEscapingTypeArguments(node);
|
||||
if (unwrappedParent is AsExpression) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.STRICT_RAW_TYPE_IN_AS, node, [node.type]);
|
||||
} else if (unwrappedParent is IsExpression) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.STRICT_RAW_TYPE_IN_IS, node, [node.type]);
|
||||
if (unwrappedParent is AsExpression || unwrappedParent is IsExpression) {
|
||||
// Do not report a "Strict raw type" error in this case; too noisy.
|
||||
// See https://github.com/dart-lang/language/blob/master/resources/type-system/strict-raw-types.md#conditions-for-a-raw-type-hint
|
||||
} else {
|
||||
_errorReporter
|
||||
.reportErrorForNode(HintCode.STRICT_RAW_TYPE, node, [node.type]);
|
||||
|
|
|
@ -4457,9 +4457,9 @@ main() {
|
|||
|
||||
{
|
||||
Object isCheck;
|
||||
if (isCheck is /*info:STRICT_RAW_TYPE_IN_IS*/List) {}
|
||||
if (isCheck is List</*info:STRICT_RAW_TYPE_IN_IS*/List>) {}
|
||||
if (isCheck is /*info:STRICT_RAW_TYPE_IN_IS*/C) {}
|
||||
if (isCheck is List) {}
|
||||
if (isCheck is List<List>) {}
|
||||
if (isCheck is C) {}
|
||||
|
||||
if (isCheck is List<dynamic>) {}
|
||||
if (isCheck is List<int>) {}
|
||||
|
@ -4469,9 +4469,9 @@ main() {
|
|||
|
||||
{
|
||||
Object asCheck;
|
||||
var asList = asCheck as /*info:STRICT_RAW_TYPE_IN_AS*/List;
|
||||
var asMap = asCheck as Map<dynamic, /*info:STRICT_RAW_TYPE_IN_AS*/List>;
|
||||
var asC = asCheck as /*info:STRICT_RAW_TYPE_IN_AS*/C;
|
||||
var asList = asCheck as List;
|
||||
var asMap = asCheck as Map<dynamic, List>;
|
||||
var asC = asCheck as C;
|
||||
}
|
||||
}
|
||||
''');
|
||||
|
|
|
@ -322,8 +322,6 @@ class AbstractStrongTest with ResourceProviderMixin {
|
|||
return code.errorSeverity.ordinal > ErrorSeverity.INFO.ordinal ||
|
||||
code == HintCode.INFERENCE_FAILURE_ON_COLLECTION_LITERAL ||
|
||||
code == HintCode.INFERENCE_FAILURE_ON_INSTANCE_CREATION ||
|
||||
code == HintCode.STRICT_RAW_TYPE_IN_AS ||
|
||||
code == HintCode.STRICT_RAW_TYPE_IN_IS ||
|
||||
code == HintCode.STRICT_RAW_TYPE;
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue