mirror of
https://github.com/dart-lang/sdk
synced 2024-09-21 09:46:28 +00:00
Issue 25733. Built-in itentifiers are not permitted as prefixes.
R=brianwilkerson@google.com BUG= https://github.com/dart-lang/sdk/issues/25733 Review-Url: https://codereview.chromium.org/2735193002 .
This commit is contained in:
parent
dd3ab83eee
commit
571aae42b8
|
@ -59,6 +59,7 @@ const List<ErrorCode> errorCodeValues = const [
|
|||
CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER,
|
||||
CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT,
|
||||
CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT,
|
||||
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_PREFIX_NAME,
|
||||
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE,
|
||||
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME,
|
||||
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME,
|
||||
|
|
|
@ -248,6 +248,20 @@ class CompileTimeErrorCode extends ErrorCode {
|
|||
"The await expression can only be used in an asynchronous function.",
|
||||
"Try marking the function body with either 'async' or 'async*'.");
|
||||
|
||||
/**
|
||||
* 16.33 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a prefix, class, type parameter
|
||||
* or type alias.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the built-in identifier that is being used
|
||||
*/
|
||||
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_PREFIX_NAME =
|
||||
const CompileTimeErrorCode(
|
||||
'BUILT_IN_IDENTIFIER_AS_PREFIX_NAME',
|
||||
"The built-in identifier '{0}' can't be used as a prefix name.",
|
||||
"Try choosing a different name for the prefix.");
|
||||
|
||||
/**
|
||||
* 12.30 Identifier Reference: It is a compile-time error to use a built-in
|
||||
* identifier other than dynamic as a type annotation.
|
||||
|
@ -262,9 +276,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
|||
"Try correcting the name to match an existing type.");
|
||||
|
||||
/**
|
||||
* 12.30 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a class, type parameter or type
|
||||
* alias.
|
||||
* 16.33 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a prefix, class, type parameter
|
||||
* or type alias.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the built-in identifier that is being used
|
||||
|
@ -276,9 +290,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
|||
"Try choosing a different name for the type.");
|
||||
|
||||
/**
|
||||
* 12.30 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a class, type parameter or type
|
||||
* alias.
|
||||
* 16.33 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a prefix, class, type parameter
|
||||
* or type alias.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the built-in identifier that is being used
|
||||
|
@ -290,9 +304,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
|||
"Try choosing a different name for the typedef.");
|
||||
|
||||
/**
|
||||
* 12.30 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a class, type parameter or type
|
||||
* alias.
|
||||
* 16.33 Identifier Reference: It is a compile-time error if a built-in
|
||||
* identifier is used as the declared name of a prefix, class, type parameter
|
||||
* or type alias.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the built-in identifier that is being used
|
||||
|
|
|
@ -900,6 +900,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
|||
@override
|
||||
Object visitImportDirective(ImportDirective node) {
|
||||
ImportElement importElement = node.element;
|
||||
if (node.prefix != null) {
|
||||
_checkForBuiltInIdentifierAsName(
|
||||
node.prefix, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_PREFIX_NAME);
|
||||
}
|
||||
if (importElement != null) {
|
||||
_checkForImportDuplicateLibraryName(node, importElement);
|
||||
_checkForImportInternalLibrary(node, importElement);
|
||||
|
|
|
@ -624,6 +624,16 @@ class as = A with B;''');
|
|||
verify([source]);
|
||||
}
|
||||
|
||||
test_builtInIdentifierAsPrefixName() async {
|
||||
Source source = addSource("import 'dart:async' as abstract;");
|
||||
await computeAnalysisResult(source);
|
||||
assertErrors(source, [
|
||||
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_PREFIX_NAME,
|
||||
HintCode.UNUSED_IMPORT
|
||||
]);
|
||||
verify([source]);
|
||||
}
|
||||
|
||||
test_builtInIdentifierAsType_formalParameter_field() async {
|
||||
Source source = addSource(r'''
|
||||
class A {
|
||||
|
|
|
@ -2195,17 +2195,6 @@ class B {
|
|||
verify([source]);
|
||||
}
|
||||
|
||||
test_implicitThisReferenceInInitializer_importPrefix() async {
|
||||
Source source = addSource(r'''
|
||||
import 'dart:async' as abstract;
|
||||
class A {
|
||||
var v = new abstract.Completer();
|
||||
}''');
|
||||
await computeAnalysisResult(source);
|
||||
assertNoErrors(source);
|
||||
verify([source]);
|
||||
}
|
||||
|
||||
test_implicitThisReferenceInInitializer_prefixedIdentifier() async {
|
||||
Source source = addSource(r'''
|
||||
class A {
|
||||
|
|
|
@ -26,22 +26,6 @@ Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context
|
|||
Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context_invocation_t04: MissingCompileTimeError # Please triage this failure.
|
||||
Language/Expressions/Function_Invocation/Unqualified_Invocation/invocation_t17: MissingCompileTimeError # Please triage this failure
|
||||
Language/Expressions/Function_Invocation/Unqualified_Invocation/invocation_t18: MissingCompileTimeError # Please triage this failure
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t53: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t54: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t55: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t56: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t57: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t58: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t59: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t60: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t61: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t62: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t63: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t64: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t65: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t66: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t67: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_identifier_t68: MissingCompileTimeError # Issue 25733
|
||||
Language/Expressions/Identifier_Reference/built_in_not_dynamic_t17: MissingCompileTimeError # Please triage this failure.
|
||||
Language/Expressions/Identifier_Reference/built_in_not_dynamic_t18: MissingCompileTimeError # Please triage this failure.
|
||||
Language/Expressions/Identifier_Reference/built_in_not_dynamic_t19: MissingCompileTimeError # Please triage this failure.
|
||||
|
|
Loading…
Reference in a new issue