diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart index 7337eb58d96..6cd2625ff05 100644 --- a/pkg/analyzer/lib/src/error/codes.dart +++ b/pkg/analyzer/lib/src/error/codes.dart @@ -1188,6 +1188,10 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { // #### Common fixes // // Choose a different name for the extension. + // TODO(brianwilkerson) When the documentation for + // 'BUILT_IN_IDENTIFIER_IN_DECLARATION' is committed it should replace the + // text above and the name of this code should be changed to match it. We + // also need to add a forward for this code at the same time. static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME = CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME', "The built-in identifier '{0}' can't be used as an extension name.", @@ -1203,9 +1207,10 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { * 0: the built-in identifier that is being used */ static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_PREFIX_NAME = - CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_PREFIX_NAME', + CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION', "The built-in identifier '{0}' can't be used as a prefix name.", - correction: "Try choosing a different name for the prefix."); + correction: "Try choosing a different name for the prefix.", + uniqueName: 'BUILT_IN_IDENTIFIER_AS_PREFIX_NAME'); /** * Parameters: @@ -1247,9 +1252,10 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { * 0: the built-in identifier that is being used */ static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_NAME = - CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPE_NAME', + CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION', "The built-in identifier '{0}' can't be used as a type name.", - correction: "Try choosing a different name for the type."); + correction: "Try choosing a different name for the type.", + uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_NAME'); /** * 16.33 Identifier Reference: It is a compile-time error if a built-in @@ -1261,10 +1267,11 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { */ static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME = CompileTimeErrorCode( - 'BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME', + 'BUILT_IN_IDENTIFIER_IN_DECLARATION', "The built-in identifier '{0}' can't be used as a type parameter " "name.", - correction: "Try choosing a different name for the type parameter."); + correction: "Try choosing a different name for the type parameter.", + uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME'); /** * 16.33 Identifier Reference: It is a compile-time error if a built-in @@ -1275,9 +1282,10 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { * 0: the built-in identifier that is being used */ static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME = - CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME', + CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION', "The built-in identifier '{0}' can't be used as a typedef name.", - correction: "Try choosing a different name for the typedef."); + correction: "Try choosing a different name for the typedef.", + uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME'); /** * No parameters. diff --git a/tests/language/identifier/built_in_illegal_test.dart b/tests/language/identifier/built_in_illegal_test.dart index 983a8542cf0..12be975cb80 100644 --- a/tests/language/identifier/built_in_illegal_test.dart +++ b/tests/language/identifier/built_in_illegal_test.dart @@ -6,15 +6,15 @@ // Pseudo keywords are not allowed to be used as class names. class abstract { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'abstract' as a name here. class as { } // ^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'as' as a name here. class dynamic { } // ^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'dynamic' as a name here. class export { } // ^^^^^^ @@ -38,11 +38,11 @@ class export { } // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN class external { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'external' as a name here. class factory { } // ^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'factory' as a name here. class get { } // ^^^ @@ -56,7 +56,7 @@ class get { } // [cfe] Expected an identifier, but got 'get'. class interface { } // ^^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'interface' as a name here. class implements { } // ^^^^^^^^^^ @@ -118,7 +118,7 @@ class library { } // [cfe] Expected a declaration, but got '}'. class operator { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'operator' as a name here. class part { } // ^^^^ @@ -152,7 +152,7 @@ class set { } // [cfe] Expected an identifier, but got 'set'. class static { } // ^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'static' as a name here. class typedef { } // ^^^^^^^ diff --git a/tests/language_2/identifier/built_in_illegal_test.dart b/tests/language_2/identifier/built_in_illegal_test.dart index 983a8542cf0..12be975cb80 100644 --- a/tests/language_2/identifier/built_in_illegal_test.dart +++ b/tests/language_2/identifier/built_in_illegal_test.dart @@ -6,15 +6,15 @@ // Pseudo keywords are not allowed to be used as class names. class abstract { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'abstract' as a name here. class as { } // ^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'as' as a name here. class dynamic { } // ^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'dynamic' as a name here. class export { } // ^^^^^^ @@ -38,11 +38,11 @@ class export { } // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN class external { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'external' as a name here. class factory { } // ^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'factory' as a name here. class get { } // ^^^ @@ -56,7 +56,7 @@ class get { } // [cfe] Expected an identifier, but got 'get'. class interface { } // ^^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'interface' as a name here. class implements { } // ^^^^^^^^^^ @@ -118,7 +118,7 @@ class library { } // [cfe] Expected a declaration, but got '}'. class operator { } // ^^^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'operator' as a name here. class part { } // ^^^^ @@ -152,7 +152,7 @@ class set { } // [cfe] Expected an identifier, but got 'set'. class static { } // ^^^^^^ -// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME +// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_IN_DECLARATION // [cfe] Can't use 'static' as a name here. class typedef { } // ^^^^^^^