Version 2.15.0-195.0.dev
Merge commit '9603871cfd946475cb7c0469944abd3bb6d5ee63' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index 6207ad4..bdb8699 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -7457,6 +7457,13 @@
r"""The expression can not result in a value with sound null safety because the expression type is `Never`.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Null> codeNewAsSelector = messageNewAsSelector;
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const MessageCode messageNewAsSelector = const MessageCode("NewAsSelector",
+ problemMessage: r"""'new' can only be used as a constructor reference.""");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(Token token)> templateNoFormals = const Template<
Message Function(Token token)>(
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index f1554cf..bb0643d 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -2,10 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/analysis/session.dart';
-import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:path/path.dart';
@@ -14,6 +10,7 @@
import '../tool/diagnostics/generate.dart';
import '../tool/messages/error_code_documentation_info.dart';
+import '../tool/messages/error_code_info.dart';
import 'src/dart/resolution/context_collection_resolution.dart';
main() {
@@ -111,20 +108,9 @@
'PubspecWarningCode.UNNECESSARY_DEV_DEPENDENCY',
];
- /// The absolute paths of the files containing the declarations of the error
- /// codes.
- final List<CodePath> codePaths;
-
/// The buffer to which validation errors are written.
final StringBuffer buffer = StringBuffer();
- /// The path to the file currently being verified.
- late String filePath;
-
- /// A flag indicating whether the [filePath] has already been written to the
- /// buffer.
- bool hasWrittenFilePath = false;
-
/// The name of the variable currently being verified.
late String variableName;
@@ -136,32 +122,31 @@
bool hasWrittenVariableName = false;
/// Initialize a newly created documentation validator.
- DocumentationValidator(this.codePaths);
+ DocumentationValidator();
/// Validate the documentation.
Future<void> validate() async {
- AnalysisContextCollection collection = AnalysisContextCollection(
- includedPaths:
- codePaths.map((codePath) => codePath.documentationPath).toList(),
- resourceProvider: PhysicalResourceProvider.INSTANCE);
- for (CodePath codePath in codePaths) {
- await _validateFile(_parse(collection, codePath.documentationPath));
+ for (var classEntry in analyzerMessages.entries) {
+ var errorClass = classEntry.key;
+ await _validateMessages(errorClass, classEntry.value);
+ }
+ ErrorClassInfo? errorClassIncludingCfeMessages;
+ for (var errorClass in errorClasses) {
+ if (errorClass.includeCfeMessages) {
+ if (errorClassIncludingCfeMessages != null) {
+ fail('Multiple error classes include CFE messages: '
+ '${errorClassIncludingCfeMessages.name} and ${errorClass.name}');
+ }
+ errorClassIncludingCfeMessages = errorClass;
+ await _validateMessages(
+ errorClass.name, cfeToAnalyzerErrorCodeTables.analyzerCodeToInfo);
+ }
}
if (buffer.isNotEmpty) {
fail(buffer.toString());
}
}
- /// Return the name of the code as defined in the [initializer].
- String _extractCodeName(VariableDeclaration variable) {
- var initializer = variable.initializer;
- if (initializer is MethodInvocation) {
- var firstArgument = initializer.argumentList.arguments[0];
- return (firstArgument as StringLiteral).stringValue!;
- }
- return variable.name.name;
- }
-
_SnippetData _extractSnippetData(
String snippet,
bool errorRequired,
@@ -227,24 +212,8 @@
return snippets;
}
- /// Use the analysis context [collection] to parse the file at the given
- /// [path] and return the result.
- ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
- AnalysisSession session = collection.contextFor(path).currentSession;
- var result = session.getParsedUnit(path);
- if (result is! ParsedUnitResult) {
- throw StateError('Unable to parse "$path"');
- }
- return result;
- }
-
/// Report a problem with the current error code.
void _reportProblem(String problem, {List<AnalysisError> errors = const []}) {
- if (!hasWrittenFilePath) {
- buffer.writeln();
- buffer.writeln('In $filePath');
- hasWrittenFilePath = true;
- }
if (!hasWrittenVariableName) {
buffer.writeln(' $variableName');
hasWrittenVariableName = true;
@@ -262,53 +231,43 @@
}
}
- /// Extract documentation from the file that was parsed to produce the given
- /// [result].
- Future<void> _validateFile(ParsedUnitResult result) async {
- filePath = result.path;
- hasWrittenFilePath = false;
- CompilationUnit unit = result.unit;
- for (CompilationUnitMember declaration in unit.declarations) {
- if (declaration is ClassDeclaration) {
- String className = declaration.name.name;
- for (ClassMember member in declaration.members) {
- if (member is FieldDeclaration) {
- var docs = parseErrorCodeDocumentation(member);
- if (docs != null) {
- VariableDeclaration variable = member.fields.variables[0];
- codeName = _extractCodeName(variable);
- if (codeName == 'NULLABLE_TYPE_IN_CATCH_CLAUSE') {
- DateTime.now();
- }
- variableName = '$className.${variable.name.name}';
- if (unverifiedDocs.contains(variableName)) {
- continue;
- }
- hasWrittenVariableName = false;
+ /// Extract documentation from the given [messages], which are error messages
+ /// destined for the class [className].
+ Future<void> _validateMessages(
+ String className, Map<String, ErrorCodeInfo> messages) async {
+ for (var errorEntry in messages.entries) {
+ var errorName = errorEntry.key;
+ var errorCodeInfo = errorEntry.value;
+ var docs = parseErrorCodeDocumentation(
+ '$className.$errorName', errorCodeInfo.documentation);
+ if (docs != null) {
+ codeName = errorCodeInfo.sharedName ?? errorName;
+ variableName = '$className.$errorName';
+ if (unverifiedDocs.contains(variableName)) {
+ continue;
+ }
+ hasWrittenVariableName = false;
- List<_SnippetData> exampleSnippets =
- _extractSnippets(docs, BlockSection.examples);
- _SnippetData? firstExample;
- if (exampleSnippets.isEmpty) {
- _reportProblem('No example.');
- } else {
- firstExample = exampleSnippets[0];
- }
- for (int i = 0; i < exampleSnippets.length; i++) {
- await _validateSnippet('example', i, exampleSnippets[i]);
- }
+ List<_SnippetData> exampleSnippets =
+ _extractSnippets(docs, BlockSection.examples);
+ _SnippetData? firstExample;
+ if (exampleSnippets.isEmpty) {
+ _reportProblem('No example.');
+ } else {
+ firstExample = exampleSnippets[0];
+ }
+ for (int i = 0; i < exampleSnippets.length; i++) {
+ await _validateSnippet('example', i, exampleSnippets[i]);
+ }
- List<_SnippetData> fixesSnippets =
- _extractSnippets(docs, BlockSection.commonFixes);
- for (int i = 0; i < fixesSnippets.length; i++) {
- _SnippetData snippet = fixesSnippets[i];
- if (firstExample != null) {
- snippet.auxiliaryFiles.addAll(firstExample.auxiliaryFiles);
- }
- await _validateSnippet('fixes', i, snippet);
- }
- }
+ List<_SnippetData> fixesSnippets =
+ _extractSnippets(docs, BlockSection.commonFixes);
+ for (int i = 0; i < fixesSnippets.length; i++) {
+ _SnippetData snippet = fixesSnippets[i];
+ if (firstExample != null) {
+ snippet.auxiliaryFiles.addAll(firstExample.auxiliaryFiles);
}
+ await _validateSnippet('fixes', i, snippet);
}
}
}
@@ -364,11 +323,10 @@
@TestTimeout(Timeout.factor(4))
test_diagnostics() async {
Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext;
- List<CodePath> codePaths = computeCodePaths();
//
// Validate that the input to the generator is correct.
//
- DocumentationValidator validator = DocumentationValidator(codePaths);
+ DocumentationValidator validator = DocumentationValidator();
await validator.validate();
//
// Validate that the generator has been run.
@@ -379,7 +337,7 @@
.readAsStringSync();
StringBuffer sink = StringBuffer();
- DocumentationGenerator generator = DocumentationGenerator(codePaths);
+ DocumentationGenerator generator = DocumentationGenerator();
generator.writeDocumentation(sink);
String expectedContent = sink.toString();
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index 7d0b2f9..c726a25 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -4,45 +4,23 @@
import 'dart:io';
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/analysis/session.dart';
-import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer_utilities/package_root.dart' as package_root;
import 'package:path/src/context.dart';
import '../messages/error_code_documentation_info.dart';
+import '../messages/error_code_info.dart';
/// Generate the file `diagnostics.md` based on the documentation associated
/// with the declarations of the error codes.
void main() async {
IOSink sink = File(computeOutputPath()).openWrite();
- DocumentationGenerator generator = DocumentationGenerator(computeCodePaths());
+ DocumentationGenerator generator = DocumentationGenerator();
generator.writeDocumentation(sink);
await sink.flush();
await sink.close();
}
-/// Compute a list of the code paths for the files containing diagnostics that
-/// have been documented.
-List<CodePath> computeCodePaths() {
- Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext;
- String packageRoot = pathContext.normalize(package_root.packageRoot);
- String analyzerPath = pathContext.join(packageRoot, 'analyzer');
- return CodePath.from([
- [analyzerPath, 'lib', 'src', 'dart', 'error', 'hint_codes.g.dart'],
- [analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.g.dart'],
- [analyzerPath, 'lib', 'src', 'error', 'codes.g.dart'],
- [analyzerPath, 'lib', 'src', 'pubspec', 'pubspec_warning_code.g.dart'],
- ], [
- null,
- null,
- null,
- null,
- ]);
-}
-
/// Compute the path to the file into which documentation is being generated.
String computeOutputPath() {
Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext;
@@ -52,41 +30,6 @@
analyzerPath, 'tool', 'diagnostics', 'diagnostics.md');
}
-/// A representation of the paths to the documentation and declaration of a set
-/// of diagnostic codes.
-class CodePath {
- /// The path to the file containing the declarations of the diagnostic codes
- /// that might have documentation associated with them.
- final String documentationPath;
-
- /// The path to the file containing the generated definition of the diagnostic
- /// codes that include the message, or `null` if the
- final String? declarationPath;
-
- /// Initialize a newly created code path from the [documentationPath] and
- /// [declarationPath].
- CodePath(this.documentationPath, this.declarationPath);
-
- /// Return a list of code paths computed by joining the path segments in the
- /// corresponding lists from [documentationPaths] and [declarationPaths].
- static List<CodePath> from(List<List<String>> documentationPaths,
- List<List<String>?> declarationPaths) {
- Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext;
- List<CodePath> paths = [];
- for (int i = 0; i < documentationPaths.length; i++) {
- String docPath = pathContext.joinAll(documentationPaths[i]);
-
- String? declPath;
- var declarationPath = declarationPaths[i];
- if (declarationPath != null) {
- declPath = pathContext.joinAll(declarationPath);
- }
- paths.add(CodePath(docPath, declPath));
- }
- return paths;
- }
-}
-
/// An information holder containing information about a diagnostic that was
/// extracted from the instance creation expression.
class DiagnosticInformation {
@@ -152,17 +95,24 @@
/// A class used to generate diagnostic documentation.
class DocumentationGenerator {
- /// The absolute paths of the files containing the declarations of the error
- /// codes.
- final List<CodePath> codePaths;
-
/// A map from the name of a diagnostic to the information about that
/// diagnostic.
Map<String, DiagnosticInformation> infoByName = {};
/// Initialize a newly created documentation generator.
- DocumentationGenerator(this.codePaths) {
- _extractAllDocs();
+ DocumentationGenerator() {
+ for (var classEntry in analyzerMessages.entries) {
+ _extractAllDocs(classEntry.key, classEntry.value);
+ }
+ for (var errorClass in errorClasses) {
+ if (errorClass.includeCfeMessages) {
+ _extractAllDocs(
+ errorClass.name, cfeToAnalyzerErrorCodeTables.analyzerCodeToInfo);
+ // Note: only one error class has the `includeCfeMessages` flag set;
+ // verify_diagnostics_test.dart verifies this. So we can safely break.
+ break;
+ }
+ }
}
/// Write the documentation to the file at the given [outputPath].
@@ -175,76 +125,36 @@
/// Extract documentation from all of the files containing the definitions of
/// diagnostics.
- void _extractAllDocs() {
- List<String> includedPaths = [];
- for (CodePath codePath in codePaths) {
- includedPaths.add(codePath.documentationPath);
- var declarationPath = codePath.declarationPath;
- if (declarationPath != null) {
- includedPaths.add(declarationPath);
- }
- }
- AnalysisContextCollection collection = AnalysisContextCollection(
- includedPaths: includedPaths,
- resourceProvider: PhysicalResourceProvider.INSTANCE);
- for (CodePath codePath in codePaths) {
- String docPath = codePath.documentationPath;
- var declPath = codePath.declarationPath;
- if (declPath == null) {
- _extractDocs(_parse(collection, docPath), null);
- } else {
- File file = File(declPath);
- if (file.existsSync()) {
- _extractDocs(
- _parse(collection, docPath), _parse(collection, declPath));
- } else {
- _extractDocs(_parse(collection, docPath), null);
- }
- }
- }
- }
-
- /// Extract information about a diagnostic from the [expression], or `null` if
- /// the expression does not appear to be creating an error code. If the
- /// expression is the name of a generated code, then the [generatedResult]
- /// should have the unit in which the information can be found.
- DiagnosticInformation? _extractDiagnosticInformation(
- Expression expression, ParsedUnitResult? generatedResult) {
- List<Expression>? arguments;
- if (expression is InstanceCreationExpression) {
- arguments = expression.argumentList.arguments;
- } else if (expression is MethodInvocation) {
- var name = expression.methodName.name;
- if (name.endsWith('Code') || name.endsWith('CodeWithUniqueName')) {
- arguments = expression.argumentList.arguments;
- }
- }
- if (arguments != null) {
- String name = _extractName(arguments);
- String message = _extractMessage(arguments);
+ void _extractAllDocs(String className, Map<String, ErrorCodeInfo> messages) {
+ for (var errorEntry in messages.entries) {
+ var errorName = errorEntry.key;
+ var errorCodeInfo = errorEntry.value;
+ var name = errorCodeInfo.sharedName ?? errorName;
var info = infoByName[name];
+ var message = convertTemplate(
+ errorCodeInfo.computePlaceholderToIndexMap(),
+ errorCodeInfo.problemMessage);
if (info == null) {
info = DiagnosticInformation(name, message);
infoByName[name] = info;
} else {
info.addMessage(message);
}
- return info;
- }
-
- if (expression is SimpleIdentifier && generatedResult != null) {
- var variable = _findVariable(expression.name, generatedResult.unit);
- if (variable != null) {
- return _extractDiagnosticInformation(variable.initializer!, null);
+ var docs = _extractDoc('$className.$errorName', errorCodeInfo);
+ if (docs.isNotEmpty) {
+ if (info.documentation != null) {
+ throw StateError(
+ 'Documentation defined multiple times for ${info.name}');
+ }
+ info.documentation = docs;
}
}
-
- return null;
}
- /// Extract documentation from the given [field] declaration.
- String _extractDoc(FieldDeclaration field) {
- var parsedComment = parseErrorCodeDocumentation(field);
+ /// Extract documentation from the given [errorCodeInfo].
+ String _extractDoc(String errorCode, ErrorCodeInfo errorCodeInfo) {
+ var parsedComment =
+ parseErrorCodeDocumentation(errorCode, errorCodeInfo.documentation);
if (parsedComment == null) {
return '';
}
@@ -254,93 +164,6 @@
].join('\n');
}
- /// Extract documentation from the file that was parsed to produce the given
- /// [result]. If a [generatedResult] is provided, then the messages might be
- /// in the file parsed to produce the result.
- void _extractDocs(
- ParsedUnitResult result, ParsedUnitResult? generatedResult) {
- CompilationUnit unit = result.unit;
- for (CompilationUnitMember declaration in unit.declarations) {
- if (declaration is ClassDeclaration &&
- declaration.name.name != 'StrongModeCode') {
- for (ClassMember member in declaration.members) {
- if (member is FieldDeclaration &&
- member.isStatic &&
- !_isDeprecated(member)) {
- VariableDeclaration variable = member.fields.variables[0];
- var info = _extractDiagnosticInformation(
- variable.initializer!, generatedResult);
- if (info != null) {
- var docs = _extractDoc(member);
- if (docs.isNotEmpty) {
- if (info.documentation != null) {
- throw StateError(
- 'Documentation defined multiple times for ${info.name}');
- }
- info.documentation = docs;
- }
- }
- }
- }
- }
- }
- }
-
- /// Return the message extracted from the list of [arguments].
- String _extractMessage(List<Expression> arguments) {
- int positionalCount =
- arguments.where((expression) => expression is! NamedExpression).length;
- if (positionalCount == 2) {
- return _extractString(arguments[1]);
- } else if (positionalCount == 3) {
- return _extractString(arguments[2]);
- } else {
- throw StateError(
- 'Invalid number of positional arguments: $positionalCount');
- }
- }
-
- /// Return the name extracted from the list of [arguments].
- String _extractName(List<Expression> arguments) =>
- _extractString(arguments[0]);
-
- String _extractString(Expression expression) {
- if (expression is StringLiteral) {
- return expression.stringValue!;
- }
- throw StateError('Cannot extract string from $expression');
- }
-
- /// Return the declaration of the top-level variable with the [name] in the
- /// compilation unit, or `null` if there is no such variable.
- VariableDeclaration? _findVariable(String name, CompilationUnit unit) {
- for (CompilationUnitMember member in unit.declarations) {
- if (member is TopLevelVariableDeclaration) {
- for (VariableDeclaration variable in member.variables.variables) {
- if (variable.name.name == name) {
- return variable;
- }
- }
- }
- }
- return null;
- }
-
- /// Return `true` if the [field] is marked as being deprecated.
- bool _isDeprecated(FieldDeclaration field) =>
- field.metadata.any((annotation) => annotation.name.name == 'Deprecated');
-
- /// Use the analysis context [collection] to parse the file at the given
- /// [path] and return the result.
- ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
- AnalysisSession session = collection.contextFor(path).currentSession;
- var result = session.getParsedUnit(path);
- if (result is! ParsedUnitResult) {
- throw StateError('Unable to parse "$path"');
- }
- return result;
- }
-
/// Write the documentation for all of the diagnostics.
void _writeDiagnostics(StringSink sink) {
sink.write('''
diff --git a/pkg/analyzer/tool/messages/error_code_documentation_info.dart b/pkg/analyzer/tool/messages/error_code_documentation_info.dart
index 37a4a76..9eedda1 100644
--- a/pkg/analyzer/tool/messages/error_code_documentation_info.dart
+++ b/pkg/analyzer/tool/messages/error_code_documentation_info.dart
@@ -4,36 +4,20 @@
import 'dart:convert';
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/src/dart/ast/token.dart';
-
-/// Extracts comments from the declaration of [field] and interprets them as a
-/// list of [ErrorCodeDocumentationPart] objects. These objects represent
-/// user-publishable documentation about the error code, along with code blocks
-/// illustrating when the error occurs and how to fix it.
+/// Converts the given [documentation] string into a list of
+/// [ErrorCodeDocumentationPart] objects. These objects represent
+/// user-publishable documentation about the given [errorCode], along with code
+/// blocks illustrating when the error occurs and how to fix it.
List<ErrorCodeDocumentationPart>? parseErrorCodeDocumentation(
- FieldDeclaration field) {
- var comments = field.firstTokenAfterCommentAndMetadata.precedingComments;
- if (comments == null) {
+ String errorCode, String? documentation) {
+ if (documentation == null) {
return null;
}
- var className = (field.parent as ClassDeclaration).name.name;
- var errorName = field.fields.variables.single.name.name;
- var commentLines = <String>[];
- while (comments != null) {
- String lexeme = comments.lexeme;
- if (lexeme.startsWith('// ')) {
- commentLines.add(lexeme.substring(3));
- } else if (lexeme == '//') {
- commentLines.add('');
- }
- comments = comments.next as CommentToken?;
- }
- if (commentLines.isEmpty) {
+ var documentationLines = documentation.split('\n');
+ if (documentationLines.isEmpty) {
return null;
}
- var parser =
- _ErrorCodeDocumentationParser('$className.$errorName', commentLines);
+ var parser = _ErrorCodeDocumentationParser(errorCode, documentationLines);
parser.parse();
return parser.result;
}
diff --git a/pkg/analyzer/tool/messages/error_code_info.dart b/pkg/analyzer/tool/messages/error_code_info.dart
index 9a81b54..6ad0667 100644
--- a/pkg/analyzer/tool/messages/error_code_info.dart
+++ b/pkg/analyzer/tool/messages/error_code_info.dart
@@ -94,6 +94,19 @@
final String frontEndPkgPath =
normalize(join(pkg_root.packageRoot, 'front_end'));
+/// Pattern used by the front end to identify placeholders in error message
+/// strings. TODO(paulberry): share this regexp (and the code for interpreting
+/// it) between the CFE and analyzer.
+final RegExp _placeholderPattern =
+ RegExp("#\([-a-zA-Z0-9_]+\)(?:%\([0-9]*\)\.\([0-9]+\))?");
+
+/// Convert a CFE template string (which uses placeholders like `#string`) to
+/// an analyzer template string (which uses placeholders like `{0}`).
+String convertTemplate(Map<String, int> placeholderToIndexMap, String entry) {
+ return entry.replaceAllMapped(_placeholderPattern,
+ (match) => '{${placeholderToIndexMap[match.group(0)!]}}');
+}
+
/// Decodes a YAML object (obtained from `pkg/analyzer/messages.yaml`) into a
/// two-level map of [ErrorCodeInfo], indexed first by class name and then by
/// error name.
@@ -271,12 +284,6 @@
/// `messages.yaml` file. Supports both the analyzer and front_end message file
/// formats.
class ErrorCodeInfo {
- /// Pattern used by the front end to identify placeholders in error message
- /// strings. TODO(paulberry): share this regexp (and the code for interpreting
- /// it) between the CFE and analyzer.
- static final RegExp _placeholderPattern =
- RegExp("#\([-a-zA-Z0-9_]+\)(?:%\([0-9]*\)\.\([0-9]+\))?");
-
/// For error code information obtained from the CFE, the set of analyzer
/// error codes that corresponds to this error code, if any.
final List<String> analyzerCode;
@@ -336,6 +343,26 @@
problemMessage: yaml['problemMessage'] as String,
sharedName: yaml['sharedName'] as String?);
+ /// Given a messages.yaml entry, come up with a mapping from placeholder
+ /// patterns in its message strings to their corresponding indices.
+ Map<String, int> computePlaceholderToIndexMap() {
+ var mapping = <String, int>{};
+ for (var value in [problemMessage, correctionMessage]) {
+ if (value is! String) continue;
+ for (Match match in _placeholderPattern.allMatches(value)) {
+ // CFE supports a bunch of formatting options that analyzer doesn't;
+ // make sure none of those are used.
+ if (match.group(0) != '#${match.group(1)}') {
+ throw 'Template string ${json.encode(value)} contains unsupported '
+ 'placeholder pattern ${json.encode(match.group(0))}';
+ }
+
+ mapping[match.group(0)!] ??= mapping.length;
+ }
+ }
+ return mapping;
+ }
+
/// Generates a dart declaration for this error code, suitable for inclusion
/// in the error class [className]. [errorCode] is the name of the error code
/// to be generated.
@@ -343,15 +370,15 @@
var out = StringBuffer();
out.writeln('$className(');
out.writeln("'${sharedName ?? errorCode}',");
- final placeholderToIndexMap = _computePlaceholderToIndexMap();
+ final placeholderToIndexMap = computePlaceholderToIndexMap();
out.writeln(
- json.encode(_convertTemplate(placeholderToIndexMap, problemMessage)) +
+ json.encode(convertTemplate(placeholderToIndexMap, problemMessage)) +
',');
final correctionMessage = this.correctionMessage;
if (correctionMessage is String) {
out.write('correctionMessage: ');
out.writeln(json.encode(
- _convertTemplate(placeholderToIndexMap, correctionMessage)) +
+ convertTemplate(placeholderToIndexMap, correctionMessage)) +
',');
}
if (hasPublishedDocs) {
@@ -400,34 +427,6 @@
if (documentation != null) 'documentation': documentation,
};
- /// Given a messages.yaml entry, come up with a mapping from placeholder
- /// patterns in its message strings to their corresponding indices.
- Map<String, int> _computePlaceholderToIndexMap() {
- var mapping = <String, int>{};
- for (var value in [problemMessage, correctionMessage]) {
- if (value is! String) continue;
- for (Match match in _placeholderPattern.allMatches(value)) {
- // CFE supports a bunch of formatting options that we don't; make sure
- // none of those are used.
- if (match.group(0) != '#${match.group(1)}') {
- throw 'Template string ${json.encode(value)} contains unsupported '
- 'placeholder pattern ${json.encode(match.group(0))}';
- }
-
- mapping[match.group(0)!] ??= mapping.length;
- }
- }
- return mapping;
- }
-
- /// Convert a CFE template string (which uses placeholders like `#string`) to
- /// an analyzer template string (which uses placeholders like `{0}`).
- static String _convertTemplate(
- Map<String, int> placeholderToIndexMap, String entry) {
- return entry.replaceAllMapped(_placeholderPattern,
- (match) => '{${placeholderToIndexMap[match.group(0)!]}}');
- }
-
static List<String> _decodeAnalyzerCode(Object? value) {
if (value == null) {
return const [];
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
index e85dce6..b5acdef 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
@@ -220,20 +220,21 @@
{bool isTypeArgumentsInForest = false});
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
- if (send is InvocationSelector) {
- return _helper.buildMethodInvocation(buildSimpleRead(), send.name,
- send.arguments, offsetForToken(send.token),
+ Selector selector, int operatorOffset, bool isNullAware) {
+ selector.reportNewAsSelector();
+ if (selector is InvocationSelector) {
+ return _helper.buildMethodInvocation(buildSimpleRead(), selector.name,
+ selector.arguments, offsetForToken(selector.token),
isNullAware: isNullAware,
- isConstantExpression: send.isPotentiallyConstant);
+ isConstantExpression: selector.isPotentiallyConstant);
} else {
if (_helper.constantContext != ConstantContext.none &&
- send.name != lengthName) {
+ selector.name != lengthName) {
_helper.addProblem(
messageNotAConstantExpression, fileOffset, token.length);
}
- return PropertyAccessGenerator.make(
- _helper, send.token, buildSimpleRead(), send.name, isNullAware);
+ return PropertyAccessGenerator.make(_helper, selector.token,
+ buildSimpleRead(), selector.name, isNullAware);
}
}
@@ -2642,17 +2643,18 @@
@override
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
+ Selector selector, int operatorOffset, bool isNullAware) {
+ selector.reportNewAsSelector();
if (_helper.constantContext != ConstantContext.none) {
_helper.addProblem(
messageNotAConstantExpression, fileOffset, token.length);
}
- Generator generator =
- _createInstanceAccess(send.token, send.name, isNullAware: isNullAware);
- if (send.arguments != null) {
- return generator.doInvocation(offsetForToken(send.token),
- send.typeArguments, send.arguments! as ArgumentsImpl,
- isTypeArgumentsInForest: send.isTypeArgumentsInForest);
+ Generator generator = _createInstanceAccess(selector.token, selector.name,
+ isNullAware: isNullAware);
+ if (selector.arguments != null) {
+ return generator.doInvocation(offsetForToken(selector.token),
+ selector.typeArguments, selector.arguments! as ArgumentsImpl,
+ isTypeArgumentsInForest: selector.isTypeArgumentsInForest);
} else {
return generator;
}
@@ -2878,9 +2880,10 @@
@override
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
- Object propertyAccess =
- suffixGenerator.buildSelectorAccess(send, operatorOffset, isNullAware);
+ Selector selector, int operatorOffset, bool isNullAware) {
+ selector.reportNewAsSelector();
+ Object propertyAccess = suffixGenerator.buildSelectorAccess(
+ selector, operatorOffset, isNullAware);
if (propertyAccess is Generator) {
return new DeferredAccessGenerator(
_helper, token, prefixGenerator, propertyAccess);
@@ -4059,14 +4062,15 @@
@override
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
- assert(send.name.text == send.token.lexeme,
- "'${send.name.text}' != ${send.token.lexeme}");
- Object result = qualifiedLookup(send.token);
- if (send is InvocationSelector) {
- result = _helper.finishSend(result, send.typeArguments,
- send.arguments as ArgumentsImpl, send.fileOffset,
- isTypeArgumentsInForest: send.isTypeArgumentsInForest);
+ Selector selector, int operatorOffset, bool isNullAware) {
+ assert(selector.name.text == selector.token.lexeme,
+ "'${selector.name.text}' != ${selector.token.lexeme}");
+ selector.reportNewAsSelector();
+ Object result = qualifiedLookup(selector.token);
+ if (selector is InvocationSelector) {
+ result = _helper.finishSend(result, selector.typeArguments,
+ selector.arguments as ArgumentsImpl, selector.fileOffset,
+ isTypeArgumentsInForest: selector.isTypeArgumentsInForest);
}
if (isNullAware) {
result = _helper.wrapInLocatedProblem(
@@ -4442,21 +4446,22 @@
@override
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
- Name name = send.name;
- Arguments? arguments = send.arguments;
- int offset = offsetForToken(send.token);
- if (isInitializer && send is InvocationSelector) {
+ Selector selector, int operatorOffset, bool isNullAware) {
+ Name name = selector.name;
+ Arguments? arguments = selector.arguments;
+ int offset = offsetForToken(selector.token);
+ if (isInitializer && selector is InvocationSelector) {
if (isNullAware) {
_helper.addProblem(
messageInvalidUseOfNullAwareAccess, operatorOffset, 2);
}
return buildConstructorInitializer(offset, name, arguments!);
}
+ selector.reportNewAsSelector();
if (inFieldInitializer && !inLateFieldInitializer && !isInitializer) {
return buildFieldInitializerError(null);
}
- if (send is InvocationSelector) {
+ if (selector is InvocationSelector) {
// Notice that 'this' or 'super' can't be null. So we can ignore the
// value of [isNullAware].
if (isNullAware) {
@@ -4465,8 +4470,8 @@
return _helper.buildMethodInvocation(
_forest.createThisExpression(fileOffset),
name,
- send.arguments,
- offsetForToken(send.token),
+ selector.arguments,
+ offsetForToken(selector.token),
isSuper: isSuper);
} else {
if (isSuper) {
@@ -4476,7 +4481,7 @@
return new SuperPropertyAccessGenerator(
_helper,
// TODO(ahe): This is not the 'super' token.
- send.token,
+ selector.token,
name,
getter,
setter);
@@ -4484,7 +4489,7 @@
return new ThisPropertyAccessGenerator(
_helper,
// TODO(ahe): This is not the 'this' token.
- send.token,
+ selector.token,
name,
thisOffset: fileOffset,
isNullAware: isNullAware);
@@ -4751,20 +4756,21 @@
@override
Expression_Generator buildSelectorAccess(
- Selector send, int operatorOffset, bool isNullAware) {
- if (send is InvocationSelector) {
- return _helper.buildMethodInvocation(
- _createRead(), send.name, send.arguments, offsetForToken(send.token),
+ Selector selector, int operatorOffset, bool isNullAware) {
+ selector.reportNewAsSelector();
+ if (selector is InvocationSelector) {
+ return _helper.buildMethodInvocation(_createRead(), selector.name,
+ selector.arguments, offsetForToken(selector.token),
isNullAware: isNullAware,
- isConstantExpression: send.isPotentiallyConstant);
+ isConstantExpression: selector.isPotentiallyConstant);
} else {
if (_helper.constantContext != ConstantContext.none &&
- send.name != lengthName) {
+ selector.name != lengthName) {
_helper.addProblem(
messageNotAConstantExpression, fileOffset, token.length);
}
return PropertyAccessGenerator.make(
- _helper, send.token, _createRead(), send.name, isNullAware);
+ _helper, selector.token, _createRead(), selector.name, isNullAware);
}
}
}
@@ -4822,6 +4828,14 @@
void printOn(StringSink sink);
+ /// Report an error if the selector name "new" when the constructor-tearoff
+ /// feature is enabled.
+ void reportNewAsSelector() {
+ if (name.text == 'new' && _helper.enableConstructorTearOffsInLibrary) {
+ _helper.addProblem(messageNewAsSelector, fileOffset, name.text.length);
+ }
+ }
+
@override
String toString() {
StringBuffer buffer = new StringBuffer();
@@ -4875,6 +4889,7 @@
if (receiver is Generator) {
return receiver.buildSelectorAccess(this, operatorOffset, isNullAware);
}
+ reportNewAsSelector();
return _helper.buildMethodInvocation(
_helper.toValue(receiver), name, arguments, fileOffset,
isNullAware: isNullAware);
@@ -4917,6 +4932,7 @@
if (receiver is Generator) {
return receiver.buildSelectorAccess(this, operatorOffset, isNullAware);
}
+ reportNewAsSelector();
return PropertyAccessGenerator.make(
_helper, token, _helper.toValue(receiver), name, isNullAware);
}
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index 8f81677..97ad8a0 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -608,6 +608,7 @@
NeverValueError/example: Fail
NeverValueWarning/analyzerCode: Fail
NeverValueWarning/example: Fail
+NewAsSelector/analyzerCode: Fail
NoFormals/example: Fail
NoSuchNamedParameter/example: Fail
NoUnnamedConstructorInObject/analyzerCode: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index cae1d1b..4ed6af7 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -5409,3 +5409,9 @@
experiments: constructor-tearoffs
script:
- "class C<X> { C.foo(); } bar() { C.foo<int>; }"
+
+NewAsSelector:
+ problemMessage: "'new' can only be used as a constructor reference."
+ experiments: constructor-tearoffs
+ script: |
+ method(dynamic d) => d.new;
\ No newline at end of file
diff --git a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.expect b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.expect
index fe92bd1..1d24b72 100644
--- a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.expect
+++ b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.expect
@@ -7,6 +7,18 @@
// int new = 42;
// ^^^
//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:10:11: Error: 'new' can only be used as a constructor reference.
+// new C().new is int;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:12:7: Error: 'new' can only be used as a constructor reference.
+// foo.new;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:13:7: Error: 'new' can only be used as a constructor reference.
+// foo.new();
+// ^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.transformed.expect
index fe92bd1..1d24b72 100644
--- a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.strong.transformed.expect
@@ -7,6 +7,18 @@
// int new = 42;
// ^^^
//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:10:11: Error: 'new' can only be used as a constructor reference.
+// new C().new is int;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:12:7: Error: 'new' can only be used as a constructor reference.
+// foo.new;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:13:7: Error: 'new' can only be used as a constructor reference.
+// foo.new();
+// ^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.expect b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.expect
index fe92bd1..1d24b72 100644
--- a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.expect
+++ b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.expect
@@ -7,6 +7,18 @@
// int new = 42;
// ^^^
//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:10:11: Error: 'new' can only be used as a constructor reference.
+// new C().new is int;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:12:7: Error: 'new' can only be used as a constructor reference.
+// foo.new;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:13:7: Error: 'new' can only be used as a constructor reference.
+// foo.new();
+// ^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.transformed.expect
index fe92bd1..1d24b72 100644
--- a/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/constructor_tearoffs/issue47075.dart.weak.transformed.expect
@@ -7,6 +7,18 @@
// int new = 42;
// ^^^
//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:10:11: Error: 'new' can only be used as a constructor reference.
+// new C().new is int;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:12:7: Error: 'new' can only be used as a constructor reference.
+// foo.new;
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/issue47075.dart:13:7: Error: 'new' can only be used as a constructor reference.
+// foo.new();
+// ^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart
new file mode 100644
index 0000000..acbe41e
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'new_as_selector.dart' as prefix1;
+import 'new_as_selector.dart' deferred as prefix2 hide E;
+
+int new = 87; // error
+
+C c = C();
+
+class Super {}
+
+class C extends Super {
+ int new = 42; // error
+
+ C() : super.new(); // ok
+ C.named() : this.new(); // ok
+
+ method() {
+ this.new; // error
+ this.new(); // error
+ this.new<int>(); // error
+ this.new = 87; // error
+ }
+}
+
+extension E on int {
+ external int new; // error
+
+ call<T>() {}
+}
+
+method(dynamic d) => d.new; // error
+
+test() {
+ new C().new; // error
+ new C().new(); // error
+ new C().new = 87; // error
+ C c = C();
+ c.new; // error
+ c.new = 87; // error
+ dynamic foo;
+ foo.new; // error
+ foo.new(); // error
+ foo.new<int>(); // error
+ foo?.new; // error
+ foo?.new(); // error
+ foo?.new<int>(); // error
+ foo..new; // error
+ foo..new(); // error
+ foo..new<int>(); // error
+ (foo).new; // error
+ (foo).new(); // error
+ (foo).new<int>(); // error
+ prefix1.new; // error
+ prefix1.new(); // error
+ prefix1.new<int>(); // error
+ prefix2.c.new; // error
+ prefix2.c.new(); // error
+ prefix2.c.new<int>(); // error
+ E(0).new; // error
+ E(0).new(); // error
+ E(0).new<int>(); // error
+ unresolved.new; // error
+ unresolved.new(); // error
+ unresolved.new<int>(); // error
+}
+
+main() {
+ C.new; // ok
+ C.new(); // ok
+}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.expect
new file mode 100644
index 0000000..75ac16e
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.expect
@@ -0,0 +1,261 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:8:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:15:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:29:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:21:10: Error: 'new' can only be used as a constructor reference.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:22:10: Error: 'new' can only be used as a constructor reference.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:23:10: Error: 'new' can only be used as a constructor reference.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:24:10: Error: 'new' can only be used as a constructor reference.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:34:24: Error: 'new' can only be used as a constructor reference.
+// method(dynamic d) => d.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:37:11: Error: 'new' can only be used as a constructor reference.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:38:11: Error: 'new' can only be used as a constructor reference.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:39:11: Error: 'new' can only be used as a constructor reference.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:41:5: Error: 'new' can only be used as a constructor reference.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:42:5: Error: 'new' can only be used as a constructor reference.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:44:7: Error: 'new' can only be used as a constructor reference.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:45:7: Error: 'new' can only be used as a constructor reference.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:46:7: Error: 'new' can only be used as a constructor reference.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:47:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:48:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:49:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:50:8: Error: 'new' can only be used as a constructor reference.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:51:8: Error: 'new' can only be used as a constructor reference.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:52:8: Error: 'new' can only be used as a constructor reference.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:53:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:54:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:55:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:56:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:57:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:58:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:59:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:60:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:61:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:62:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:63:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:64:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new<int>(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final dynamic #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final dynamic #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final dynamic #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+}
+static method main() → dynamic {
+ #C1;
+ new self::C::•();
+}
+
+constants {
+ #C1 = constructor-tearoff self::C::•
+}
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.transformed.expect
new file mode 100644
index 0000000..16d0ea0
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.transformed.expect
@@ -0,0 +1,261 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:8:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:15:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:29:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:21:10: Error: 'new' can only be used as a constructor reference.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:22:10: Error: 'new' can only be used as a constructor reference.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:23:10: Error: 'new' can only be used as a constructor reference.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:24:10: Error: 'new' can only be used as a constructor reference.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:34:24: Error: 'new' can only be used as a constructor reference.
+// method(dynamic d) => d.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:37:11: Error: 'new' can only be used as a constructor reference.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:38:11: Error: 'new' can only be used as a constructor reference.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:39:11: Error: 'new' can only be used as a constructor reference.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:41:5: Error: 'new' can only be used as a constructor reference.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:42:5: Error: 'new' can only be used as a constructor reference.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:44:7: Error: 'new' can only be used as a constructor reference.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:45:7: Error: 'new' can only be used as a constructor reference.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:46:7: Error: 'new' can only be used as a constructor reference.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:47:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:48:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:49:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:50:8: Error: 'new' can only be used as a constructor reference.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:51:8: Error: 'new' can only be used as a constructor reference.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:52:8: Error: 'new' can only be used as a constructor reference.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:53:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:54:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:55:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:56:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:57:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:58:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:59:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:60:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:61:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:62:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:63:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:64:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new<int>(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final core::Object* #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final core::Object* #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final core::Object* #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+}
+static method main() → dynamic {
+ #C1;
+ new self::C::•();
+}
+
+constants {
+ #C1 = constructor-tearoff self::C::•
+}
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.textual_outline.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.textual_outline.expect
new file mode 100644
index 0000000..6902541
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.textual_outline.expect
@@ -0,0 +1,18 @@
+import 'new_as_selector.dart' as prefix1;
+import 'new_as_selector.dart' deferred as prefix2 hide E;
+int new = 87;
+C c = C();
+class Super {}
+class C extends Super {
+ int new = 42;
+ C() : super.new();
+ C.named() : this.new();
+ method() {}
+}
+extension E on int {
+ external int new;
+ call<T>() {}
+}
+method(dynamic d) => d.new;
+test() {}
+main() {}
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.expect
new file mode 100644
index 0000000..75ac16e
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.expect
@@ -0,0 +1,261 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:8:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:15:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:29:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:21:10: Error: 'new' can only be used as a constructor reference.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:22:10: Error: 'new' can only be used as a constructor reference.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:23:10: Error: 'new' can only be used as a constructor reference.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:24:10: Error: 'new' can only be used as a constructor reference.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:34:24: Error: 'new' can only be used as a constructor reference.
+// method(dynamic d) => d.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:37:11: Error: 'new' can only be used as a constructor reference.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:38:11: Error: 'new' can only be used as a constructor reference.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:39:11: Error: 'new' can only be used as a constructor reference.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:41:5: Error: 'new' can only be used as a constructor reference.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:42:5: Error: 'new' can only be used as a constructor reference.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:44:7: Error: 'new' can only be used as a constructor reference.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:45:7: Error: 'new' can only be used as a constructor reference.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:46:7: Error: 'new' can only be used as a constructor reference.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:47:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:48:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:49:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:50:8: Error: 'new' can only be used as a constructor reference.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:51:8: Error: 'new' can only be used as a constructor reference.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:52:8: Error: 'new' can only be used as a constructor reference.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:53:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:54:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:55:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:56:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:57:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:58:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:59:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:60:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:61:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:62:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:63:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:64:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new<int>(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final dynamic #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final dynamic #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final dynamic #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+}
+static method main() → dynamic {
+ #C1;
+ new self::C::•();
+}
+
+constants {
+ #C1 = constructor-tearoff self::C::•
+}
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.outline.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.outline.expect
new file mode 100644
index 0000000..661e8d1
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.outline.expect
@@ -0,0 +1,58 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:8:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:15:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:29:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ ;
+}
+class C extends self::Super {
+ field core::int new;
+ constructor •() → self::C
+ ;
+ constructor named() → self::C
+ ;
+ method method() → dynamic
+ ;
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new;
+static field self::C c;
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic
+ ;
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ ;
+static method test() → dynamic
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.transformed.expect
new file mode 100644
index 0000000..16d0ea0
--- /dev/null
+++ b/pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.weak.transformed.expect
@@ -0,0 +1,261 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:8:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:15:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:29:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:21:10: Error: 'new' can only be used as a constructor reference.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:22:10: Error: 'new' can only be used as a constructor reference.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:23:10: Error: 'new' can only be used as a constructor reference.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:24:10: Error: 'new' can only be used as a constructor reference.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:34:24: Error: 'new' can only be used as a constructor reference.
+// method(dynamic d) => d.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:37:11: Error: 'new' can only be used as a constructor reference.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:38:11: Error: 'new' can only be used as a constructor reference.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:39:11: Error: 'new' can only be used as a constructor reference.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:41:5: Error: 'new' can only be used as a constructor reference.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:42:5: Error: 'new' can only be used as a constructor reference.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:44:7: Error: 'new' can only be used as a constructor reference.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:45:7: Error: 'new' can only be used as a constructor reference.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:46:7: Error: 'new' can only be used as a constructor reference.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:47:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:48:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:49:8: Error: 'new' can only be used as a constructor reference.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:50:8: Error: 'new' can only be used as a constructor reference.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:51:8: Error: 'new' can only be used as a constructor reference.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:52:8: Error: 'new' can only be used as a constructor reference.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:53:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:54:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:55:9: Error: 'new' can only be used as a constructor reference.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:56:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:57:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:58:11: Error: 'new' can only be used as a constructor reference.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:59:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:60:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:61:13: Error: 'new' can only be used as a constructor reference.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:62:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:63:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:64:8: Error: 'new' can only be used as a constructor reference.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:14: Error: 'new' can only be used as a constructor reference.
+// unresolved.new<int>(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final core::Object* #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final core::Object* #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final core::Object* #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:65:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:66:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+}
+static method main() → dynamic {
+ #C1;
+ new self::C::•();
+}
+
+constants {
+ #C1 = constructor-tearoff self::C::•
+}
diff --git a/pkg/front_end/testcases/general/new_as_selector.dart b/pkg/front_end/testcases/general/new_as_selector.dart
new file mode 100644
index 0000000..103aa67
--- /dev/null
+++ b/pkg/front_end/testcases/general/new_as_selector.dart
@@ -0,0 +1,75 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// @dart=2.14
+
+import 'new_as_selector.dart' as prefix1;
+import 'new_as_selector.dart' deferred as prefix2 hide E;
+
+int new = 87; // error
+
+C c = C();
+
+class Super {}
+
+class C extends Super {
+ int new = 42; // error
+
+ C() : super.new(); // error
+ C.named() : this.new(); // error
+
+ method() {
+ this.new; // error
+ this.new(); // error
+ this.new<int>(); // error
+ this.new = 87; // error
+ }
+}
+
+extension E on int {
+ external int new; // error
+
+ call<T>() {}
+}
+
+method(dynamic d) => d.new; // error
+
+test() {
+ new C().new; // error
+ new C().new(); // error
+ new C().new = 87; // error
+ C c = C();
+ c.new; // error
+ c.new = 87; // error
+ dynamic foo;
+ foo.new; // error
+ foo.new(); // error
+ foo.new<int>(); // error
+ foo?.new; // error
+ foo?.new(); // error
+ foo?.new<int>(); // error
+ foo..new; // error
+ foo..new(); // error
+ foo..new<int>(); // error
+ (foo).new; // error
+ (foo).new(); // error
+ (foo).new<int>(); // error
+ prefix1.new; // error
+ prefix1.new(); // error
+ prefix1.new<int>(); // error
+ prefix2.c.new; // error
+ prefix2.c.new(); // error
+ prefix2.c.new<int>(); // error
+ E(0).new; // error
+ E(0).new(); // error
+ E(0).new<int>(); // error
+ unresolved.new; // error
+ unresolved.new(); // error
+ unresolved.new<int>(); // error
+ C.new; // error
+ C.new(); // error
+}
+
+main() {
+}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/general/new_as_selector.dart.textual_outline.expect b/pkg/front_end/testcases/general/new_as_selector.dart.textual_outline.expect
new file mode 100644
index 0000000..9084629
--- /dev/null
+++ b/pkg/front_end/testcases/general/new_as_selector.dart.textual_outline.expect
@@ -0,0 +1,19 @@
+// @dart = 2.14
+import 'new_as_selector.dart' as prefix1;
+import 'new_as_selector.dart' deferred as prefix2 hide E;
+int new = 87;
+C c = C();
+class Super {}
+class C extends Super {
+ int new = 42;
+ C() : super.new();
+ C.named() : this.new();
+ method() {}
+}
+extension E on int {
+ external int new;
+ call<T>() {}
+}
+method(dynamic d) => d.new;
+test() {}
+main() {}
diff --git a/pkg/front_end/testcases/general/new_as_selector.dart.weak.expect b/pkg/front_end/testcases/general/new_as_selector.dart.weak.expect
new file mode 100644
index 0000000..01083e9
--- /dev/null
+++ b/pkg/front_end/testcases/general/new_as_selector.dart.weak.expect
@@ -0,0 +1,311 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:10:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:17:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:19:15: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C() : super.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:20:20: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.named() : this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:31:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:23:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:24:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:25:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:26:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:39:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:40:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:41:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:43:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:44:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:46:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:47:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:48:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:49:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:50:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:51:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:52:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:53:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:54:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:55:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:56:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:57:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:58:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:59:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:60:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:61:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:62:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:63:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:64:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:65:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:66:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:67:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:68:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:68:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:69:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:69:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: Member not found: 'new'.
+// C.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:71:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.new(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final dynamic #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final dynamic #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final dynamic #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:68:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:69:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: Member not found: 'new'.
+ C.new; // error
+ ^^^";
+ new self::C::•();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/new_as_selector.dart.weak.outline.expect b/pkg/front_end/testcases/general/new_as_selector.dart.weak.outline.expect
new file mode 100644
index 0000000..6772b34
--- /dev/null
+++ b/pkg/front_end/testcases/general/new_as_selector.dart.weak.outline.expect
@@ -0,0 +1,68 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:10:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:17:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:19:15: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C() : super.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:20:20: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.named() : this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:31:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ ;
+}
+class C extends self::Super {
+ field core::int new;
+ constructor •() → self::C
+ ;
+ constructor named() → self::C
+ ;
+ method method() → dynamic
+ ;
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new;
+static field self::C c;
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic
+ ;
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ ;
+static method test() → dynamic
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/new_as_selector.dart.weak.transformed.expect b/pkg/front_end/testcases/general/new_as_selector.dart.weak.transformed.expect
new file mode 100644
index 0000000..0ecdf2a
--- /dev/null
+++ b/pkg/front_end/testcases/general/new_as_selector.dart.weak.transformed.expect
@@ -0,0 +1,311 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:10:5: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:17:7: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// int new = 42; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:19:15: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C() : super.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:20:20: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.named() : this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:31:16: Error: 'new' can't be used as an identifier because it's a keyword.
+// Try renaming this to be an identifier that isn't a keyword.
+// external int new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:23:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:24:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:25:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:26:10: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// this.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:39:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:40:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:41:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// new C().new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:43:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:44:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// c.new = 87; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:46:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:47:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:48:7: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:49:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:50:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:51:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo?.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:52:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:53:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:54:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// foo..new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:55:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:56:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:57:9: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// (foo).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:58:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:59:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:60:11: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix1.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:61:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:62:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:63:13: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// prefix2.c.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:64:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:65:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:66:8: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// E(0).new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:67:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+// unresolved.new; // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:68:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:68:3: Error: Undefined name 'unresolved'.
+// unresolved.new(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:69:14: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// unresolved.new<int>(); // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:69:3: Error: Undefined name 'unresolved'.
+// unresolved.new<int>(); // error
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: Member not found: 'new'.
+// C.new; // error
+// ^^^
+//
+// pkg/front_end/testcases/general/new_as_selector.dart:71:5: Error: This requires the 'constructor-tearoffs' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// C.new(); // error
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///new_as_selector.dart" as prefix1;
+import "org-dartlang-testcase:///new_as_selector.dart" deferred as prefix2 hide E;
+
+class Super extends core::Object {
+ synthetic constructor •() → self::Super
+ : super core::Object::•()
+ ;
+}
+class C extends self::Super {
+ field core::int new = 42;
+ constructor •() → self::C
+ : super self::Super::•()
+ ;
+ constructor named() → self::C
+ : this self::C::•()
+ ;
+ method method() → dynamic {
+ this.{self::C::new}{core::int};
+ self::E|call<dynamic>(this.{self::C::new}{core::int});
+ self::E|call<core::int>(this.{self::C::new}{core::int});
+ this.{self::C::new} = 87;
+ }
+}
+extension E on core::int {
+ get new = self::E|get#new;
+ set new = self::E|set#new;
+ method call = self::E|call;
+ tearoff call = self::E|get#call;
+}
+static field core::int new = 87;
+static field self::C c = new self::C::•();
+external static method E|get#new(core::int #this) → core::int;
+external static method E|set#new(core::int #this, core::int #externalFieldValue) → void;
+static method E|call<T extends core::Object? = dynamic>(lowered final core::int #this) → dynamic {}
+static method E|get#call(lowered final core::int #this) → <T extends core::Object? = dynamic>() → dynamic
+ return <T extends core::Object? = dynamic>() → dynamic => self::E|call<T%>(#this);
+static method method(dynamic d) → dynamic
+ return d{dynamic}.new;
+static method test() → dynamic {
+ new self::C::•().{self::C::new}{core::int};
+ self::E|call<dynamic>(new self::C::•().{self::C::new}{core::int});
+ new self::C::•().{self::C::new} = 87;
+ self::C c = new self::C::•();
+ c.{self::C::new}{core::int};
+ c.{self::C::new} = 87;
+ dynamic foo;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ let final dynamic #t1 = foo in #t1 == null ?{dynamic} null : #t1{dynamic}.new;
+ let final dynamic #t2 = foo in #t2 == null ?{dynamic} null : #t2{dynamic}.new();
+ let final dynamic #t3 = foo in #t3 == null ?{dynamic} null : #t3{dynamic}.new<core::int>();
+ let final dynamic #t4 = foo in block {
+ #t4{dynamic}.new;
+ } =>#t4;
+ let final dynamic #t5 = foo in block {
+ #t5{dynamic}.new();
+ } =>#t5;
+ let final dynamic #t6 = foo in block {
+ #t6{dynamic}.new<core::int>();
+ } =>#t6;
+ foo{dynamic}.new;
+ foo{dynamic}.new();
+ foo{dynamic}.new<core::int>();
+ self::new;
+ self::E|call<dynamic>(self::new);
+ self::E|call<core::int>(self::new);
+ let final core::Object* #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
+ let final core::Object* #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
+ let final core::Object* #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
+ self::E|get#new(0);
+ self::E|call<dynamic>(self::E|get#new(0));
+ self::E|call<core::int>(self::E|get#new(0));
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:67:3: Error: Undefined name 'unresolved'.
+ unresolved.new; // error
+ ^^^^^^^^^^"{<invalid>}.new;
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:68:3: Error: Undefined name 'unresolved'.
+ unresolved.new(); // error
+ ^^^^^^^^^^"{dynamic}.new();
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:69:3: Error: Undefined name 'unresolved'.
+ unresolved.new<int>(); // error
+ ^^^^^^^^^^"{dynamic}.new<core::int>();
+ invalid-expression "pkg/front_end/testcases/general/new_as_selector.dart:70:5: Error: Member not found: 'new'.
+ C.new; // error
+ ^^^";
+ new self::C::•();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/no_such_method_forwarder.dart b/pkg/front_end/testcases/general/no_such_method_forwarder.dart
index 5155aa6..b2938fc 100644
--- a/pkg/front_end/testcases/general/no_such_method_forwarder.dart
+++ b/pkg/front_end/testcases/general/no_such_method_forwarder.dart
@@ -1,7 +1,9 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+
// @dart=2.9
+
class X {
void _foo() async {
await null;
diff --git a/pkg/front_end/testcases/general/no_such_method_forwarder.dart.weak.outline.expect b/pkg/front_end/testcases/general/no_such_method_forwarder.dart.weak.outline.expect
index 3f9946a..a58f8ef 100644
--- a/pkg/front_end/testcases/general/no_such_method_forwarder.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/no_such_method_forwarder.dart.weak.outline.expect
@@ -44,12 +44,12 @@
Extra constant evaluation status:
-Evaluated: SymbolLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:6:8 -> SymbolConstant(#_foo)
-Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:6:8 -> ListConstant(const <Type*>[])
-Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:6:8 -> ListConstant(const <dynamic>[])
-Evaluated: MapLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:6:8 -> MapConstant(const <Symbol*, dynamic>{})
-Evaluated: SymbolLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:11:8 -> SymbolConstant(#foo)
-Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:11:8 -> ListConstant(const <Type*>[])
-Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:11:8 -> ListConstant(const <dynamic>[])
-Evaluated: MapLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:11:8 -> MapConstant(const <Symbol*, dynamic>{})
+Evaluated: SymbolLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:8:8 -> SymbolConstant(#_foo)
+Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:8:8 -> ListConstant(const <Type*>[])
+Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:8:8 -> ListConstant(const <dynamic>[])
+Evaluated: MapLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:8:8 -> MapConstant(const <Symbol*, dynamic>{})
+Evaluated: SymbolLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:13:8 -> SymbolConstant(#foo)
+Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:13:8 -> ListConstant(const <Type*>[])
+Evaluated: ListLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:13:8 -> ListConstant(const <dynamic>[])
+Evaluated: MapLiteral @ org-dartlang-testcase:///no_such_method_forwarder.dart:13:8 -> MapConstant(const <Symbol*, dynamic>{})
Extra constant evaluation: evaluated: 16, effectively constant: 8
diff --git a/pkg/front_end/testcases/textual_outline.status b/pkg/front_end/testcases/textual_outline.status
index b53b921..344af28 100644
--- a/pkg/front_end/testcases/textual_outline.status
+++ b/pkg/front_end/testcases/textual_outline.status
@@ -25,6 +25,7 @@
const_functions/const_functions_const_factory: FormatterCrash
constructor_tearoffs/issue46133: FormatterCrash
constructor_tearoffs/issue47075: FormatterCrash
+constructor_tearoffs/new_as_selector: FormatterCrash
dart2js/late_fields: FormatterCrash
dart2js/late_statics: FormatterCrash
extension_types/basic_show: FormatterCrash
@@ -88,6 +89,7 @@
general/issue45700.crash: FormatterCrash
general/many_errors: FormatterCrash
general/missing_prefix_name: FormatterCrash
+general/new_as_selector: FormatterCrash
general/null_aware_super: FormatterCrash
general/null_safety_invalid_experiment: FormatterCrash
general/null_safety_invalid_experiment_and_language_version: FormatterCrash
diff --git a/tools/VERSION b/tools/VERSION
index b897739..41b9984 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 194
+PRERELEASE 195
PRERELEASE_PATCH 0
\ No newline at end of file