Version 2.16.0-146.0.dev
Merge commit 'bd3fbd16826c568d5b5e1a566aa48a3c5f188c1a' into 'dev'
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 77326fb..a3ae779 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -365,6 +365,8 @@
CompileTimeErrorCode.PART_OF_DIFFERENT_LIBRARY,
CompileTimeErrorCode.PART_OF_NON_PART,
CompileTimeErrorCode.PART_OF_UNNAMED_LIBRARY,
+ CompileTimeErrorCode
+ .POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT,
CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER,
CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
CompileTimeErrorCode.PREFIX_SHADOWED_BY_LOCAL_DECLARATION,
@@ -403,6 +405,8 @@
CompileTimeErrorCode.SHARED_DEFERRED_PREFIX,
CompileTimeErrorCode.SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.STATIC_ACCESS_TO_INSTANCE_MEMBER,
+ CompileTimeErrorCode.SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED,
+ CompileTimeErrorCode.SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL,
CompileTimeErrorCode.SUPER_IN_EXTENSION,
CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT,
CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR,
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 0a2341a..eabe7ee 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -5482,14 +5482,17 @@
if (superConstructor != null) {
var superParameters = superConstructor.parameters;
if (isNamed) {
- return superParameters.firstWhereOrNull((e) => e.name == name);
+ return superParameters
+ .firstWhereOrNull((e) => e.isNamed && e.name == name);
} else {
+ var positionalSuperParameters =
+ superParameters.where((e) => e.isPositional).toList();
var index = enclosingElement.parameters
.whereType<SuperFormalParameterElementImpl>()
.toList()
.indexOf(this);
- if (index >= 0 && index < superParameters.length) {
- return superParameters[index];
+ if (index >= 0 && index < positionalSuperParameters.length) {
+ return positionalSuperParameters[index];
}
}
}
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
index 0f00d43..5f42ff2 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -11628,6 +11628,20 @@
);
/**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT =
+ CompileTimeErrorCode(
+ 'POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT',
+ "Positional super-formal parameters can't be used when the "
+ "super-constructor invocation has a positional argument.",
+ correctionMessage:
+ "Try removing the 'super' modifier, or changing the super-constructor "
+ "to use named parameters.",
+ );
+
+ /**
* Parameters:
* 0: the name of the prefix
*/
@@ -13078,6 +13092,30 @@
);
/**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED = CompileTimeErrorCode(
+ 'SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED',
+ "No associated named super-constructor parameter.",
+ correctionMessage: "Try changing the name to the name of an existing named "
+ "super-constructor parameter, or creating such named parameter.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL =
+ CompileTimeErrorCode(
+ 'SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL',
+ "No associated positional super-constructor parameter.",
+ correctionMessage:
+ "Try using named parameters instead, or adding more positional "
+ "parameters to the super-constructor.",
+ );
+
+ /**
* 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
* is a compile-time error if a generative constructor of class Object
* includes a superinitializer.
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index c430007..344c5e7 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -406,7 +406,11 @@
return;
}
var argumentList = node.argumentList;
- var parameters = _resolveArgumentsToFunction(argumentList, element);
+ var parameters = _resolveArgumentsToFunction(
+ argumentList,
+ element,
+ enclosingConstructor: node.thisOrAncestorOfType<ConstructorDeclaration>(),
+ );
if (parameters != null) {
argumentList.correspondingStaticParameters = parameters;
}
@@ -446,12 +450,19 @@
/// cannot be matched to a parameter. Return the parameters that correspond to
/// the arguments, or `null` if no correspondence could be computed.
List<ParameterElement?>? _resolveArgumentsToFunction(
- ArgumentList argumentList, ExecutableElement? executableElement) {
+ ArgumentList argumentList,
+ ExecutableElement? executableElement, {
+ ConstructorDeclaration? enclosingConstructor,
+ }) {
if (executableElement == null) {
return null;
}
List<ParameterElement> parameters = executableElement.parameters;
- return _resolveArgumentsToParameters(argumentList, parameters);
+ return _resolveArgumentsToParameters(
+ argumentList,
+ parameters,
+ enclosingConstructor: enclosingConstructor,
+ );
}
/// Given an [argumentList] and the [parameters] related to the element that
@@ -460,9 +471,16 @@
/// the arguments cannot be matched to a parameter. Return the parameters that
/// correspond to the arguments.
List<ParameterElement?> _resolveArgumentsToParameters(
- ArgumentList argumentList, List<ParameterElement> parameters) {
+ ArgumentList argumentList,
+ List<ParameterElement> parameters, {
+ ConstructorDeclaration? enclosingConstructor,
+ }) {
return ResolverVisitor.resolveArgumentsToParameters(
- argumentList, parameters, _errorReporter.reportErrorForNode);
+ argumentList,
+ parameters,
+ _errorReporter.reportErrorForNode,
+ enclosingConstructor: enclosingConstructor,
+ );
}
/// Resolve the names in the given [combinators] in the scope of the given
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index ddcbc07..ad495d9 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -2331,11 +2331,12 @@
/// Returns the parameters that correspond to the arguments. If no parameter
/// matched an argument, that position will be `null` in the list.
static List<ParameterElement?> resolveArgumentsToParameters(
- ArgumentList argumentList,
- List<ParameterElement> parameters,
- void Function(ErrorCode errorCode, AstNode node,
- [List<Object> arguments])?
- onError) {
+ ArgumentList argumentList,
+ List<ParameterElement> parameters,
+ void Function(ErrorCode errorCode, AstNode node, [List<Object> arguments])?
+ onError, {
+ ConstructorDeclaration? enclosingConstructor,
+ }) {
if (parameters.isEmpty && argumentList.arguments.isEmpty) {
return const <ParameterElement>[];
}
@@ -2401,6 +2402,45 @@
}
}
}
+
+ if (enclosingConstructor != null) {
+ var hasExplicitPositionalArguments = positionalArgumentCount != 0;
+ for (var formalParameter in enclosingConstructor.parameters.parameters) {
+ formalParameter = formalParameter.notDefault;
+ if (formalParameter is SuperFormalParameter) {
+ var element = formalParameter.declaredElement
+ as SuperFormalParameterElementImpl;
+ if (formalParameter.isNamed) {
+ if (onError != null && element.superConstructorParameter == null) {
+ onError(
+ CompileTimeErrorCode
+ .SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED,
+ formalParameter.identifier,
+ );
+ }
+ } else {
+ positionalArgumentCount++;
+ if (onError != null) {
+ if (hasExplicitPositionalArguments) {
+ onError(
+ CompileTimeErrorCode
+ .POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT,
+ formalParameter.identifier,
+ );
+ }
+ if (element.superConstructorParameter == null) {
+ onError(
+ CompileTimeErrorCode
+ .SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL,
+ formalParameter.identifier,
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
if (positionalArgumentCount < requiredParameterCount && noBlankArguments) {
if (onError != null) {
onError(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS,
@@ -2417,8 +2457,8 @@
} else {
errorCode = CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS;
}
- if (onError != null) {
- onError(errorCode, firstUnresolvedArgument!,
+ if (onError != null && firstUnresolvedArgument != null) {
+ onError(errorCode, firstUnresolvedArgument,
[unnamedParameterCount, positionalArgumentCount]);
}
}
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index fc0b1e9..0f6e2fe 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -9866,6 +9866,10 @@
```dart
part of 'test.dart';
```
+ POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT:
+ problemMessage: Positional super-formal parameters can't be used when the super-constructor invocation has a positional argument.
+ comment: No parameters.
+ correctionMessage: Try removing the 'super' modifier, or changing the super-constructor to use named parameters.
PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER:
problemMessage: "The name '{0}' is already used as an import prefix and can't be used to name a top-level element."
correctionMessage: Try renaming either the top-level element or the prefix.
@@ -11098,6 +11102,14 @@
int f(C c) => c.b;
```
+ SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED:
+ problemMessage: No associated named super-constructor parameter.
+ comment: No parameters.
+ correctionMessage: Try changing the name to the name of an existing named super-constructor parameter, or creating such named parameter.
+ SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL:
+ problemMessage: No associated positional super-constructor parameter.
+ comment: No parameters.
+ correctionMessage: Try using named parameters instead, or adding more positional parameters to the super-constructor.
IMPLEMENTS_DEFERRED_CLASS:
sharedName: SUBTYPE_OF_DEFERRED_CLASS
problemMessage: "Classes and mixins can't implement deferred classes."
diff --git a/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart b/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
index e8e1418..dcb8a8f 100644
--- a/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
@@ -86,4 +86,28 @@
error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 65, 2),
]);
}
+
+ test_superParameter_optional() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ A(int? a);
+}
+
+class B extends A {
+ B([super.a]) : super();
+}
+''');
+ }
+
+ test_superParameter_required() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ A(int a);
+}
+
+class B extends A {
+ B(super.a) : super();
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/positional_super_formal_parameter_with_positional_argument_test.dart b/pkg/analyzer/test/src/diagnostics/positional_super_formal_parameter_with_positional_argument_test.dart
new file mode 100644
index 0000000..ddde7c2
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/positional_super_formal_parameter_with_positional_argument_test.dart
@@ -0,0 +1,49 @@
+// 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 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(
+ PositionalSuperFormalParameterWithPositionalArgumentTest);
+ });
+}
+
+@reflectiveTest
+class PositionalSuperFormalParameterWithPositionalArgumentTest
+ extends PubPackageResolutionTest {
+ test_notReported() async {
+ await assertNoErrorsInCode(r'''
+class A {
+ A(int a);
+}
+
+class B extends A {
+ B(super.a) : super();
+}
+''');
+ }
+
+ test_reported() async {
+ await assertErrorsInCode(r'''
+class A {
+ A(int a, int b);
+}
+
+class B extends A {
+ B(super.b) : super(0);
+}
+''', [
+ error(
+ CompileTimeErrorCode
+ .POSITIONAL_SUPER_FORMAL_PARAMETER_WITH_POSITIONAL_ARGUMENT,
+ 62,
+ 1)
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_named_test.dart b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_named_test.dart
new file mode 100644
index 0000000..049858a
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_named_test.dart
@@ -0,0 +1,52 @@
+// 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 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(SuperFormalParameterWithoutAssociatedNamedTest);
+ });
+}
+
+@reflectiveTest
+class SuperFormalParameterWithoutAssociatedNamedTest
+ extends PubPackageResolutionTest {
+ test_optional() async {
+ await assertErrorsInCode(r'''
+class A {
+ A([int? a]);
+}
+
+class B extends A {
+ B({super.a}) : super();
+}
+''', [
+ error(
+ CompileTimeErrorCode.SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED,
+ 59,
+ 1)
+ ]);
+ }
+
+ test_required() async {
+ await assertErrorsInCode(r'''
+class A {
+ A([int? a]);
+}
+
+class B extends A {
+ B({required super.a}) : super();
+}
+''', [
+ error(
+ CompileTimeErrorCode.SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED,
+ 68,
+ 1)
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_positional_test.dart b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_positional_test.dart
new file mode 100644
index 0000000..47d5cde
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_without_associated_positional_test.dart
@@ -0,0 +1,54 @@
+// 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 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(SuperFormalParameterWithoutAssociatedPositionalTest);
+ });
+}
+
+@reflectiveTest
+class SuperFormalParameterWithoutAssociatedPositionalTest
+ extends PubPackageResolutionTest {
+ test_optional() async {
+ await assertErrorsInCode(r'''
+class A {
+ A({int? a});
+}
+
+class B extends A {
+ B([super.a]) : super();
+}
+''', [
+ error(
+ CompileTimeErrorCode
+ .SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL,
+ 59,
+ 1)
+ ]);
+ }
+
+ test_required() async {
+ await assertErrorsInCode(r'''
+class A {
+ A({int? a});
+}
+
+class B extends A {
+ B(super.a) : super();
+}
+''', [
+ error(
+ CompileTimeErrorCode
+ .SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL,
+ 58,
+ 1)
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index 8bed89d..445a54b 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -546,6 +546,8 @@
import 'packed_nesting_non_packed_test.dart' as packed_nesting_non_packed;
import 'part_of_different_library_test.dart' as part_of_different_library;
import 'part_of_non_part_test.dart' as part_of_non_part;
+import 'positional_super_formal_parameter_with_positional_argument_test.dart'
+ as positional_super_formal_parameter_with_positional_argument;
import 'prefix_collides_with_top_level_member_test.dart'
as prefix_collides_with_top_level_member;
import 'prefix_identifier_not_followed_by_dot_test.dart'
@@ -626,6 +628,10 @@
import 'subtype_of_ffi_class_test.dart' as subtype_of_ffi_class;
import 'subtype_of_sealed_class_test.dart' as subtype_of_sealed_class;
import 'subtype_of_struct_class_test.dart' as subtype_of_struct_class;
+import 'super_formal_parameter_without_associated_named_test.dart'
+ as super_formal_parameter_without_associated_named;
+import 'super_formal_parameter_without_associated_positional_test.dart'
+ as super_formal_parameter_without_associated_positional;
import 'super_in_extension_test.dart' as super_in_extension;
import 'super_in_invalid_context_test.dart' as super_in_invalid_context;
import 'super_in_redirecting_constructor_test.dart'
@@ -1089,6 +1095,7 @@
packed_nesting_non_packed.main();
part_of_different_library.main();
part_of_non_part.main();
+ positional_super_formal_parameter_with_positional_argument.main();
prefix_collides_with_top_level_member.main();
prefix_identifier_not_followed_by_dot.main();
prefix_shadowed_by_local_declaration.main();
@@ -1139,6 +1146,8 @@
subtype_of_ffi_class.main();
subtype_of_sealed_class.main();
subtype_of_struct_class.main();
+ super_formal_parameter_without_associated_named.main();
+ super_formal_parameter_without_associated_positional.main();
super_in_extension.main();
super_in_invalid_context.main();
super_in_redirecting_constructor.main();
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 9ab1bc5..b5fdd89 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -1615,6 +1615,38 @@
''');
}
+ test_class_constructor_parameters_super_optionalNamed_unresolved2() async {
+ var library = await checkLibrary('''
+class A {
+ A(int a);
+}
+
+class B extends A {
+ B({super.a});
+}
+''');
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ parameters
+ requiredPositional a @18
+ type: int
+ class B @31
+ supertype: A
+ constructors
+ @47
+ parameters
+ optionalNamed final super.a @56
+ type: dynamic
+ superConstructorParameter: <null>
+ superConstructor: self::@class::A::@constructor::•
+''');
+ }
+
test_class_constructor_parameters_super_optionalPositional() async {
var library = await checkLibrary('''
class A {
@@ -1770,6 +1802,38 @@
''');
}
+ test_class_constructor_parameters_super_requiredPositional_unresolved2() async {
+ var library = await checkLibrary('''
+class A {
+ A({required int a})
+}
+
+class B extends A {
+ B(super.a);
+}
+''');
+ checkElementText(library, r'''
+library
+ definingUnit
+ classes
+ class A @6
+ constructors
+ @12
+ parameters
+ requiredNamed a @28
+ type: int
+ class B @41
+ supertype: A
+ constructors
+ @57
+ parameters
+ requiredPositional final super.a @65
+ type: dynamic
+ superConstructorParameter: <null>
+ superConstructor: self::@class::A::@constructor::•
+''');
+ }
+
test_class_constructor_params() async {
var library = await checkLibrary('class C { C(x, int y); }');
checkElementText(library, r'''
diff --git a/pkg/front_end/lib/src/fasta/builder/class_builder.dart b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
index 69e68ff..47a66ca 100644
--- a/pkg/front_end/lib/src/fasta/builder/class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
@@ -449,11 +449,12 @@
@override
void forEachDeclaredConstructor(
- void Function(String name, SourceConstructorBuilder constructorBuilder)
+ void Function(
+ String name, DeclaredSourceConstructorBuilder constructorBuilder)
callback) {
Set<String> visitedConstructorNames = {};
void callbackFilteringFieldBuilders(String name, Builder builder) {
- if (builder is SourceConstructorBuilder &&
+ if (builder is DeclaredSourceConstructorBuilder &&
visitedConstructorNames.add(builder.name)) {
callback(name, builder);
}
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
index 18d8b6d..42d99a3 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
@@ -5,9 +5,10 @@
library fasta.dill_member_builder;
import 'package:kernel/ast.dart'
- show Constructor, Field, Member, Procedure, ProcedureKind;
+ show Constructor, Field, FunctionNode, Member, Procedure, ProcedureKind;
import '../builder/builder.dart';
+import '../builder/constructor_builder.dart';
import '../builder/member_builder.dart';
import '../kernel/hierarchy/class_member.dart' show ClassMember;
@@ -223,7 +224,9 @@
Member get invokeTarget => procedure;
}
-class DillConstructorBuilder extends DillMemberBuilder {
+class DillConstructorBuilder extends DillMemberBuilder
+ implements ConstructorBuilder {
+ @override
final Constructor constructor;
final Procedure? _constructorTearOff;
@@ -232,6 +235,9 @@
: super(constructor, parent);
@override
+ FunctionNode get function => constructor.function;
+
+ @override
Constructor get member => constructor;
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 509bb49..7a00b4e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -922,7 +922,7 @@
void prepareInitializers() {
SourceFunctionBuilder member = this.member as SourceFunctionBuilder;
scope = member.computeFormalParameterInitializerScope(scope);
- if (member is SourceConstructorBuilder) {
+ if (member is DeclaredSourceConstructorBuilder) {
member.prepareInitializers();
if (member.formals != null) {
for (FormalParameterBuilder formal in member.formals!) {
@@ -1106,7 +1106,7 @@
}
}
}
- if (builder is SourceConstructorBuilder) {
+ if (builder is DeclaredSourceConstructorBuilder) {
finishConstructor(builder, asyncModifier, body);
} else if (builder is SourceProcedureBuilder) {
builder.asyncModifier = asyncModifier;
@@ -1614,7 +1614,7 @@
}
if (doFinishConstructor) {
finishConstructor(
- member as SourceConstructorBuilder, AsyncMarker.Sync, null);
+ member as DeclaredSourceConstructorBuilder, AsyncMarker.Sync, null);
}
}
@@ -1654,7 +1654,7 @@
return arguments;
}
- void finishConstructor(SourceConstructorBuilder builder,
+ void finishConstructor(DeclaredSourceConstructorBuilder builder,
AsyncMarker asyncModifier, Statement? body) {
/// Quotes below are from [Dart Programming Language Specification, 4th
/// Edition](
@@ -1773,7 +1773,7 @@
positionalArguments = positionalSuperParametersAsArguments;
namedArguments = namedSuperParametersAsArguments;
}
- if (classBuilder is EnumBuilder) {
+ if (classBuilder is SourceEnumBuilder) {
assert(constructor.function.positionalParameters.length >= 2 &&
constructor.function.positionalParameters[0].name == "index" &&
constructor.function.positionalParameters[1].name == "name");
@@ -5315,7 +5315,7 @@
}
}
if (type is ClassBuilder) {
- if (type is EnumBuilder) {
+ if (type is SourceEnumBuilder) {
return buildProblem(fasta.messageEnumInstantiation,
nameToken.charOffset, nameToken.length);
}
@@ -6895,8 +6895,8 @@
]);
}
}
- SourceConstructorBuilder constructorBuilder =
- member as SourceConstructorBuilder;
+ DeclaredSourceConstructorBuilder constructorBuilder =
+ member as DeclaredSourceConstructorBuilder;
constructorBuilder.registerInitializedField(builder);
return builder.buildInitializer(assignmentOffset, expression,
isSynthetic: formal != null);
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index ad571bc..3504c3a 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -781,7 +781,7 @@
}
}
- SyntheticConstructorBuilder _makeMixinApplicationConstructor(
+ SyntheticSourceConstructorBuilder _makeMixinApplicationConstructor(
SourceClassBuilder classBuilder,
Class mixin,
MemberBuilder superConstructorBuilder,
@@ -885,7 +885,7 @@
buildConstructorTearOffProcedure(constructorTearOff, constructor,
classBuilder.cls, classBuilder.library);
}
- return new SyntheticConstructorBuilder(
+ return new SyntheticSourceConstructorBuilder(
classBuilder, constructor, constructorTearOff,
// We pass on the original constructor and the cloned function nodes to
// ensure that the default values are computed and cloned for the
@@ -910,7 +910,7 @@
ticker.logMs("Cloned default values of formals");
}
- SyntheticConstructorBuilder _makeDefaultConstructor(
+ SyntheticSourceConstructorBuilder _makeDefaultConstructor(
SourceClassBuilder classBuilder,
Reference? constructorReference,
Reference? tearOffReference) {
@@ -940,7 +940,7 @@
buildConstructorTearOffProcedure(constructorTearOff, constructor,
classBuilder.cls, classBuilder.library);
}
- return new SyntheticConstructorBuilder(
+ return new SyntheticSourceConstructorBuilder(
classBuilder, constructor, constructorTearOff);
}
@@ -1162,17 +1162,17 @@
Set<FieldBuilder>? initializedFields = null;
builder.forEachDeclaredConstructor(
- (String name, SourceConstructorBuilder constructorBuilder) {
+ (String name, DeclaredSourceConstructorBuilder constructorBuilder) {
if (constructorBuilder.isExternal) return;
// In case of duplicating constructors the earliest ones (those that
// declared towards the beginning of the file) come last in the list.
// To report errors on the first definition of a constructor, we need to
// iterate until that last element.
- SourceConstructorBuilder earliest = constructorBuilder;
+ DeclaredSourceConstructorBuilder earliest = constructorBuilder;
Builder earliestBuilder = constructorBuilder;
while (earliestBuilder.next != null) {
earliestBuilder = earliestBuilder.next!;
- if (earliestBuilder is SourceConstructorBuilder) {
+ if (earliestBuilder is DeclaredSourceConstructorBuilder) {
earliest = earliestBuilder;
}
}
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
index ab8d175..f24e48b 100644
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
@@ -352,7 +352,7 @@
final BodyBuilder listener = createFunctionListener(
lookupBuilder(beginToken, getOrSet, name as String)
- as FunctionBuilderImpl);
+ as SourceFunctionBuilderImpl);
buildFunctionBody(listener, bodyToken, metadata, MemberKind.TopLevelMethod);
}
@@ -599,8 +599,8 @@
checkEmpty(beginToken.charOffset);
if (name is ParserRecovery || currentClassIsParserRecovery) return;
- FunctionBuilderImpl builder =
- lookupConstructor(beginToken, name!) as FunctionBuilderImpl;
+ SourceFunctionBuilderImpl builder =
+ lookupConstructor(beginToken, name!) as SourceFunctionBuilderImpl;
if (_inRedirectingFactory) {
buildRedirectingFactoryMethod(
bodyToken, builder, MemberKind.Factory, metadata);
@@ -709,12 +709,13 @@
Token? metadata = pop() as Token?;
checkEmpty(beginToken.charOffset);
if (name is ParserRecovery || currentClassIsParserRecovery) return;
- FunctionBuilderImpl builder;
+ SourceFunctionBuilderImpl builder;
if (isConstructor) {
- builder = lookupConstructor(beginToken, name!) as FunctionBuilderImpl;
+ builder =
+ lookupConstructor(beginToken, name!) as SourceFunctionBuilderImpl;
} else {
builder = lookupBuilder(beginToken, getOrSet, name as String)
- as FunctionBuilderImpl;
+ as SourceFunctionBuilderImpl;
}
buildFunctionBody(
createFunctionListener(builder),
@@ -778,7 +779,7 @@
..constantContext = constantContext;
}
- BodyBuilder createFunctionListener(FunctionBuilderImpl builder) {
+ BodyBuilder createFunctionListener(SourceFunctionBuilderImpl builder) {
final Scope typeParameterScope =
builder.computeTypeParameterScope(memberScope);
final Scope formalParameterScope =
@@ -795,8 +796,8 @@
inferenceDataForTesting: builder.dataForTesting?.inferenceData);
}
- void buildRedirectingFactoryMethod(Token token, FunctionBuilderImpl builder,
- MemberKind kind, Token? metadata) {
+ void buildRedirectingFactoryMethod(Token token,
+ SourceFunctionBuilderImpl builder, MemberKind kind, Token? metadata) {
final BodyBuilder listener = createFunctionListener(builder);
try {
Parser parser = new Parser(listener,
diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
index b623395..51311fb 100644
--- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
@@ -559,7 +559,7 @@
});
forEachConstructor((String name, MemberBuilder builder) {
- if (builder is SourceConstructorBuilder) {
+ if (builder is DeclaredSourceConstructorBuilder) {
library.checkTypesInConstructorBuilder(builder, typeEnvironment);
} else if (builder is RedirectingFactoryBuilder) {
library.checkTypesInRedirectingFactoryBuilder(builder, typeEnvironment);
@@ -575,7 +575,8 @@
}, includeInjectedConstructors: true);
}
- void addSyntheticConstructor(SyntheticConstructorBuilder constructorBuilder) {
+ void addSyntheticConstructor(
+ SyntheticSourceConstructorBuilder constructorBuilder) {
String name = constructorBuilder.name;
constructorBuilder.next = constructorScopeBuilder[name];
constructorScopeBuilder.addMember(name, constructorBuilder);
diff --git a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
index 8fbed56..36e33bc 100644
--- a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
@@ -48,8 +48,11 @@
import '../util/helpers.dart' show DelayedActionPerformer;
import 'source_function_builder.dart';
-class SourceConstructorBuilder extends FunctionBuilderImpl
- implements ConstructorBuilder {
+abstract class SourceConstructorBuilder
+ implements ConstructorBuilder, SourceMemberBuilder {}
+
+class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
+ implements SourceConstructorBuilder {
final Constructor _constructor;
final Procedure? _constructorTearOff;
@@ -65,7 +68,7 @@
Token? beginInitializers;
- SourceConstructorBuilder? actualOrigin;
+ DeclaredSourceConstructorBuilder? actualOrigin;
Constructor get actualConstructor => _constructor;
@@ -79,7 +82,7 @@
@override
List<FormalParameterBuilder>? formals;
- SourceConstructorBuilder(
+ DeclaredSourceConstructorBuilder(
List<MetadataBuilder>? metadata,
int modifiers,
TypeBuilder? returnType,
@@ -138,7 +141,7 @@
Iterable<Member> get exportedMembers => [constructor];
@override
- SourceConstructorBuilder get origin => actualOrigin ?? this;
+ DeclaredSourceConstructorBuilder get origin => actualOrigin ?? this;
ConstructorBuilder? get patchForTesting =>
dataForTesting?.patchForTesting as ConstructorBuilder?;
@@ -310,12 +313,12 @@
Object? superTargetBuilder = _computeSuperTargetBuilder();
Constructor superTarget;
List<FormalParameterBuilder>? superFormals;
- if (superTargetBuilder is SourceConstructorBuilder) {
+ if (superTargetBuilder is DeclaredSourceConstructorBuilder) {
superTarget = superTargetBuilder.constructor;
superFormals = superTargetBuilder.formals!;
} else if (superTargetBuilder is DillConstructorBuilder) {
superTarget = superTargetBuilder.constructor;
- if (superTargetBuilder is SyntheticConstructorBuilder) {
+ if (superTargetBuilder is SyntheticSourceConstructorBuilder) {
superFormals = superTargetBuilder.formals;
} else {
// The error in this case should be reported elsewhere. Here we perform
@@ -334,11 +337,11 @@
return performRecoveryForErroneousCase();
}
- if (superTargetBuilder is SourceConstructorBuilder) {
+ if (superTargetBuilder is DeclaredSourceConstructorBuilder) {
superTargetBuilder.inferFormalTypes(classHierarchy);
- } else if (superTargetBuilder is SyntheticConstructorBuilder) {
+ } else if (superTargetBuilder is SyntheticSourceConstructorBuilder) {
MemberBuilder? superTargetOriginBuilder = superTargetBuilder.actualOrigin;
- if (superTargetOriginBuilder is SourceConstructorBuilder) {
+ if (superTargetOriginBuilder is DeclaredSourceConstructorBuilder) {
superTargetOriginBuilder.inferFormalTypes(classHierarchy);
}
}
@@ -457,10 +460,10 @@
void addSuperParameterDefaultValueCloners(
List<SynthesizedFunctionNode> synthesizedFunctionNodes) {
Object? superTargetBuilder = _computeSuperTargetBuilder();
- if (superTargetBuilder is SourceConstructorBuilder) {
+ if (superTargetBuilder is DeclaredSourceConstructorBuilder) {
superTargetBuilder
.addSuperParameterDefaultValueCloners(synthesizedFunctionNodes);
- } else if (superTargetBuilder is SyntheticConstructorBuilder) {
+ } else if (superTargetBuilder is SyntheticSourceConstructorBuilder) {
superTargetBuilder
.addSuperParameterDefaultValueCloners(synthesizedFunctionNodes);
}
@@ -621,7 +624,7 @@
@override
void applyPatch(Builder patch) {
- if (patch is SourceConstructorBuilder) {
+ if (patch is DeclaredSourceConstructorBuilder) {
if (checkPatch(patch)) {
patch.actualOrigin = this;
dataForTesting?.patchForTesting = patch;
@@ -683,7 +686,7 @@
}
}
-class SyntheticConstructorBuilder extends DillConstructorBuilder
+class SyntheticSourceConstructorBuilder extends DillConstructorBuilder
with SourceMemberBuilderMixin {
// TODO(johnniwinther,cstefantsova): Rename [_origin] to avoid the confusion
// with patches.
@@ -693,7 +696,7 @@
MemberBuilder? _origin;
SynthesizedFunctionNode? _synthesizedFunctionNode;
- SyntheticConstructorBuilder(SourceClassBuilder parent,
+ SyntheticSourceConstructorBuilder(SourceClassBuilder parent,
Constructor constructor, Procedure? constructorTearOff,
{MemberBuilder? origin, SynthesizedFunctionNode? synthesizedFunctionNode})
: _origin = origin,
@@ -704,7 +707,7 @@
// confusion with patches.
MemberBuilder? get actualOrigin {
MemberBuilder? origin = _origin;
- while (origin is SyntheticConstructorBuilder) {
+ while (origin is SyntheticSourceConstructorBuilder) {
origin = origin._origin;
}
return origin;
@@ -712,7 +715,7 @@
List<FormalParameterBuilder>? get formals {
MemberBuilder? origin = actualOrigin;
- return origin is SourceConstructorBuilder ? origin.formals : null;
+ return origin is DeclaredSourceConstructorBuilder ? origin.formals : null;
}
@override
@@ -728,10 +731,10 @@
// If [_origin] is from a source library, we need to build the default
// values and initializers first.
MemberBuilder origin = _origin!;
- if (origin is SourceConstructorBuilder) {
+ if (origin is DeclaredSourceConstructorBuilder) {
origin.buildOutlineExpressions(originLibraryBuilder, classHierarchy,
delayedActionPerformers, synthesizedFunctionNodes);
- } else if (origin is SyntheticConstructorBuilder) {
+ } else if (origin is SyntheticSourceConstructorBuilder) {
origin.buildOutlineExpressions(originLibraryBuilder, classHierarchy,
delayedActionPerformers, synthesizedFunctionNodes);
}
@@ -744,9 +747,9 @@
void addSuperParameterDefaultValueCloners(
List<SynthesizedFunctionNode> synthesizedFunctionNodes) {
MemberBuilder? origin = _origin;
- if (origin is SourceConstructorBuilder) {
+ if (origin is DeclaredSourceConstructorBuilder) {
origin.addSuperParameterDefaultValueCloners(synthesizedFunctionNodes);
- } else if (origin is SyntheticConstructorBuilder) {
+ } else if (origin is SyntheticSourceConstructorBuilder) {
origin.addSuperParameterDefaultValueCloners(synthesizedFunctionNodes);
}
if (_synthesizedFunctionNode != null) {
diff --git a/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart b/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
index 9e13bbc..216861b 100644
--- a/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
@@ -75,7 +75,7 @@
import 'source_library_builder.dart' show SourceLibraryBuilder;
import 'source_procedure_builder.dart';
-class EnumBuilder extends SourceClassBuilder {
+class SourceEnumBuilder extends SourceClassBuilder {
final List<EnumConstantInfo?>? enumConstantInfos;
final NamedTypeBuilder intType;
@@ -86,9 +86,9 @@
final NamedTypeBuilder listType;
- SourceConstructorBuilder? _synthesizedDefaultConstructorBuilder;
+ DeclaredSourceConstructorBuilder? _synthesizedDefaultConstructorBuilder;
- EnumBuilder.internal(
+ SourceEnumBuilder.internal(
List<MetadataBuilder>? metadata,
String name,
List<TypeVariableBuilder>? typeVariables,
@@ -124,7 +124,7 @@
referencesFromIndexed,
cls: cls);
- factory EnumBuilder(
+ factory SourceEnumBuilder(
List<MetadataBuilder>? metadata,
String name,
List<TypeVariableBuilder>? typeVariables,
@@ -270,34 +270,35 @@
fieldSetterReference: valuesSetterReference);
members["values"] = valuesBuilder;
- SourceConstructorBuilder? synthesizedDefaultConstructorBuilder;
+ DeclaredSourceConstructorBuilder? synthesizedDefaultConstructorBuilder;
if (constructorScope.local.isEmpty) {
- synthesizedDefaultConstructorBuilder = new SourceConstructorBuilder(
- /* metadata = */ null,
- constMask,
- /* returnType = */ null,
- "",
- /* typeParameters = */ null,
- <FormalParameterBuilder>[
- new FormalParameterBuilder(
- null, 0, intType, "index", parent, charOffset),
- new FormalParameterBuilder(
- null, 0, stringType, "name", parent, charOffset)
- ],
- parent,
- charOffset,
- charOffset,
- charOffset,
- charEndOffset,
- constructorReference,
- tearOffReference,
- forAbstractClassOrEnum: true);
+ synthesizedDefaultConstructorBuilder =
+ new DeclaredSourceConstructorBuilder(
+ /* metadata = */ null,
+ constMask,
+ /* returnType = */ null,
+ "",
+ /* typeParameters = */ null,
+ <FormalParameterBuilder>[
+ new FormalParameterBuilder(
+ null, 0, intType, "index", parent, charOffset),
+ new FormalParameterBuilder(
+ null, 0, stringType, "name", parent, charOffset)
+ ],
+ parent,
+ charOffset,
+ charOffset,
+ charOffset,
+ charEndOffset,
+ constructorReference,
+ tearOffReference,
+ forAbstractClassOrEnum: true);
synthesizedDefaultConstructorBuilder
.registerInitializedField(valuesBuilder);
constructors[""] = synthesizedDefaultConstructorBuilder;
} else {
constructorScope.forEach((name, member) {
- if (member is SourceConstructorBuilder) {
+ if (member is DeclaredSourceConstructorBuilder) {
member.ensureGrowableFormals();
member.formals!.insert(
0,
@@ -401,7 +402,7 @@
scope.forEachLocalSetter((name, member) {
setters[name] = member;
});
- EnumBuilder enumBuilder = new EnumBuilder.internal(
+ SourceEnumBuilder enumBuilder = new SourceEnumBuilder.internal(
metadata,
name,
typeVariables,
@@ -539,7 +540,6 @@
classHierarchy.coreTypes,
new ListLiteral(values,
typeArgument: rawType(library.nonNullable), isConst: true));
-
int index = 0;
if (enumConstantInfos != null) {
for (EnumConstantInfo? enumConstantInfo in enumConstantInfos!) {
diff --git a/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart b/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart
index 56e6800..5d02635 100644
--- a/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart
@@ -33,7 +33,7 @@
import 'source_loader.dart' show SourceLoader;
import 'source_member_builder.dart';
-class SourceFactoryBuilder extends FunctionBuilderImpl {
+class SourceFactoryBuilder extends SourceFunctionBuilderImpl {
final int charOpenParenOffset;
AsyncMarker actualAsyncModifier = AsyncMarker.Sync;
diff --git a/pkg/front_end/lib/src/fasta/source/source_function_builder.dart b/pkg/front_end/lib/src/fasta/source/source_function_builder.dart
index c29ad33..52c156d 100644
--- a/pkg/front_end/lib/src/fasta/source/source_function_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_function_builder.dart
@@ -126,7 +126,7 @@
}
/// Common base class for constructor and procedure builders.
-abstract class FunctionBuilderImpl extends SourceMemberBuilderImpl
+abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
implements SourceFunctionBuilder {
@override
final List<MetadataBuilder>? metadata;
@@ -155,7 +155,7 @@
/// extension declaration.
List<TypeParameter>? _extensionTypeParameters;
- FunctionBuilderImpl(
+ SourceFunctionBuilderImpl(
this.metadata,
this.modifiers,
this.returnType,
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index b60f0ec..4070f2c 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -2534,22 +2534,23 @@
.lookupGetterReference(constructorTearOffName(
constructorName, _currentClassReferencesFromIndexed!.library));
}
- SourceConstructorBuilder constructorBuilder = new SourceConstructorBuilder(
- metadata,
- modifiers & ~abstractMask,
- returnType,
- constructorName,
- typeVariables,
- formals,
- this,
- startCharOffset,
- charOffset,
- charOpenParenOffset,
- charEndOffset,
- constructorReference,
- tearOffReference,
- nativeMethodName: nativeMethodName,
- forAbstractClassOrEnum: forAbstractClass);
+ DeclaredSourceConstructorBuilder constructorBuilder =
+ new DeclaredSourceConstructorBuilder(
+ metadata,
+ modifiers & ~abstractMask,
+ returnType,
+ constructorName,
+ typeVariables,
+ formals,
+ this,
+ startCharOffset,
+ charOffset,
+ charOpenParenOffset,
+ charEndOffset,
+ constructorReference,
+ tearOffReference,
+ nativeMethodName: nativeMethodName,
+ forAbstractClassOrEnum: forAbstractClass);
checkTypeVariables(typeVariables, constructorBuilder);
// TODO(johnniwinther): There is no way to pass the tear off reference here.
addBuilder(constructorName, constructorBuilder, charOffset,
@@ -2816,7 +2817,7 @@
Map<String, MemberBuilder> constructors = declaration.constructors!;
Map<String, MemberBuilder> setters = declaration.setters!;
- EnumBuilder enumBuilder = new EnumBuilder(
+ SourceEnumBuilder enumBuilder = new SourceEnumBuilder(
metadata,
name,
typeVariables,
@@ -3046,7 +3047,7 @@
if (!declaration.isPatch && !declaration.isDuplicate) {
library.addTypedef(typedef);
}
- } else if (declaration is EnumBuilder) {
+ } else if (declaration is SourceEnumBuilder) {
Class cls = declaration.build(this, coreLibrary);
if (!declaration.isPatch) {
cls.name += findDuplicateSuffix(declaration);
@@ -3661,9 +3662,9 @@
inErrorRecovery: issues.isNotEmpty);
formals = member.formals;
} else {
- assert(member is SourceConstructorBuilder,
+ assert(member is DeclaredSourceConstructorBuilder,
"Unexpected constructor member (${member.runtimeType}).");
- formals = (member as SourceConstructorBuilder).formals;
+ formals = (member as DeclaredSourceConstructorBuilder).formals;
}
if (formals != null && formals.isNotEmpty) {
for (FormalParameterBuilder formal in formals) {
@@ -4228,7 +4229,7 @@
}
void checkTypesInConstructorBuilder(
- SourceConstructorBuilder constructorBuilder,
+ DeclaredSourceConstructorBuilder constructorBuilder,
TypeEnvironment typeEnvironment) {
checkBoundsInFunctionNode(
constructorBuilder.constructor.function, typeEnvironment, fileUri);
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 4d9a9f9..07b1207 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -912,7 +912,7 @@
}
void registerConstructorToBeInferred(
- Constructor constructor, SourceConstructorBuilder builder) {
+ Constructor constructor, DeclaredSourceConstructorBuilder builder) {
_typeInferenceEngine!.toBeInferred[constructor] = builder;
}
@@ -1445,7 +1445,7 @@
}
});
classBuilder.forEachConstructor((String name, Builder memberBuilder) {
- if (memberBuilder is SourceConstructorBuilder) {
+ if (memberBuilder is DeclaredSourceConstructorBuilder) {
MacroApplications? macroApplications = computeApplications(
libraryBuilder,
classBuilder.scope,
@@ -1684,7 +1684,7 @@
directSupertypeMap.keys.toList();
for (int i = 0; i < directSupertypes.length; i++) {
TypeDeclarationBuilder? supertype = directSupertypes[i];
- if (supertype is EnumBuilder) {
+ if (supertype is SourceEnumBuilder) {
cls.addProblem(templateExtendingEnum.withArguments(supertype.name),
cls.charOffset, noLength);
} else if (!cls.library.mayImplementRestrictedTypes &&
diff --git a/pkg/front_end/lib/src/fasta/source/source_procedure_builder.dart b/pkg/front_end/lib/src/fasta/source/source_procedure_builder.dart
index a679d67..861506f 100644
--- a/pkg/front_end/lib/src/fasta/source/source_procedure_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_procedure_builder.dart
@@ -22,7 +22,7 @@
import 'source_function_builder.dart';
import 'source_member_builder.dart';
-class SourceProcedureBuilder extends FunctionBuilderImpl
+class SourceProcedureBuilder extends SourceFunctionBuilderImpl
implements ProcedureBuilder {
@override
final int charOpenParenOffset;
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
index 639f6b7..fcc9c8e 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
@@ -112,14 +112,14 @@
/// This is represented as a map from a constructor to its library
/// builder because the builder is used to report errors due to cyclic
/// inference dependencies.
- final Map<Constructor, SourceConstructorBuilder> toBeInferred = {};
+ final Map<Constructor, DeclaredSourceConstructorBuilder> toBeInferred = {};
/// A map containing constructors in the process of being inferred.
///
/// This is used to detect cyclic inference dependencies. It is represented
/// as a map from a constructor to its library builder because the builder
/// is used to report errors.
- final Map<Constructor, SourceConstructorBuilder> beingInferred = {};
+ final Map<Constructor, DeclaredSourceConstructorBuilder> beingInferred = {};
final Map<Member, TypeDependency> typeDependencies = {};
@@ -143,7 +143,7 @@
void finishTopLevelInitializingFormals() {
// Field types have all been inferred so we don't need to guard against
// cyclic dependency.
- for (SourceConstructorBuilder builder in toBeInferred.values) {
+ for (DeclaredSourceConstructorBuilder builder in toBeInferred.values) {
builder.inferFormalTypes(classHierarchy);
}
toBeInferred.clear();
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index f30fc34..44a61a4 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -365,7 +365,8 @@
@override
void inferConstructorParameterTypes(Constructor target) {
- SourceConstructorBuilder? constructor = engine.beingInferred[target];
+ DeclaredSourceConstructorBuilder? constructor =
+ engine.beingInferred[target];
if (constructor != null) {
// There is a cyclic dependency where inferring the types of the
// initializing formals of a constructor required us to infer the
diff --git a/pkg/front_end/lib/src/testing/id_testing_helper.dart b/pkg/front_end/lib/src/testing/id_testing_helper.dart
index 77a6a44..13b47b5 100644
--- a/pkg/front_end/lib/src/testing/id_testing_helper.dart
+++ b/pkg/front_end/lib/src/testing/id_testing_helper.dart
@@ -68,58 +68,53 @@
this.targetFlags: const TestTargetFlags(),
this.nnbdMode: NnbdMode.Weak});
- void customizeCompilerOptions(CompilerOptions options, TestData testData) {}
+ /// Called before running test on [testData].
+ ///
+ /// This allows tests to customize the [options] based on the [testData].
+ ///
+ /// A custom object can be returned. This is passed to data computer.
+ dynamic customizeCompilerOptions(
+ CompilerOptions options, TestData testData) =>
+ null;
}
-// TODO(johnniwinther): Support annotations for compile-time errors.
abstract class DataComputer<T> {
const DataComputer();
/// Called before testing to setup flags needed for data collection.
void setup() {}
- // Called to allow for (awaited) inspection of the compilation result.
- Future<void> inspectComponent(Component component) {
+ /// Called to allow for (awaited) inspection of the [testResultData] from
+ /// running the test.
+ Future<void> inspectTestResultData(TestResultData testResultData) {
return new Future.value(null);
}
/// Function that computes a data mapping for [member].
///
/// Fills [actualMap] with the data.
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}
/// Function that computes a data mapping for [cls].
///
/// Fills [actualMap] with the data.
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}
/// Function that computes a data mapping for [extension].
///
/// Fills [actualMap] with the data.
- void computeExtensionData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Extension extension,
+ void computeExtensionData(TestResultData testResultData, Extension extension,
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}
/// Function that computes a data mapping for [library].
///
/// Fills [actualMap] with the data.
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}
@@ -131,7 +126,7 @@
bool get supportsErrors => false;
/// Returns data corresponding to [error].
- T? computeErrorData(TestConfig config, InternalCompilerResult compiler, Id id,
+ T? computeErrorData(TestResultData testResultData, Id id,
List<FormattedMessage> errors) =>
null;
@@ -143,6 +138,21 @@
bool get includeMemberSignatures => false;
}
+/// Auxiliary data from running a test.
+class TestResultData {
+ /// The test config used to run the test.
+ final TestConfig config;
+
+ /// CustomData is passed from [TestConfig.customizeCompilerOptions].
+ final dynamic customData;
+
+ /// The compiler result from running the test, include access to the used
+ /// compiler.
+ final InternalCompilerResult compilerResult;
+
+ TestResultData(this.config, this.customData, this.compilerResult);
+}
+
class CfeCompiledData<T> extends CompiledData<T> {
final InternalCompilerResult compilerResult;
@@ -325,13 +335,16 @@
}
}
options.packagesFileUri = config.packageConfigUri;
- config.customizeCompilerOptions(options, testData);
+ dynamic customData = config.customizeCompilerOptions(options, testData);
InternalCompilerResult compilerResult = await compileScript(
testData.memorySourceFiles,
options: options,
retainDataForTesting: true,
requireMain: false) as InternalCompilerResult;
+ TestResultData testResultData =
+ new TestResultData(config, customData, compilerResult);
+
Component component = compilerResult.component!;
Map<Uri, Map<Id, ActualData<T>>> actualMaps = <Uri, Map<Id, ActualData<T>>>{};
Map<Id, ActualData<T>> globalData = <Id, ActualData<T>>{};
@@ -362,8 +375,7 @@
offset = 0;
}
NodeId id = new NodeId(offset, IdKind.error);
- T? data =
- dataComputer.computeErrorData(config, compilerResult, id, list);
+ T? data = dataComputer.computeErrorData(testResultData, id, list);
if (data != null) {
Map<Id, ActualData<T>> actualMap = actualMapForUri(uri);
actualMap[id] = new ActualData<T>(id, data, uri, offset, list);
@@ -398,18 +410,17 @@
return;
}
}
- dataComputer.computeMemberData(config, compilerResult, member, actualMap,
+ dataComputer.computeMemberData(testResultData, member, actualMap,
verbose: verbose);
}
void processClass(Class cls, Map<Id, ActualData<T>> actualMap) {
- dataComputer.computeClassData(config, compilerResult, cls, actualMap,
+ dataComputer.computeClassData(testResultData, cls, actualMap,
verbose: verbose);
}
void processExtension(Extension extension, Map<Id, ActualData<T>> actualMap) {
- dataComputer.computeExtensionData(
- config, compilerResult, extension, actualMap,
+ dataComputer.computeExtensionData(testResultData, extension, actualMap,
verbose: verbose);
}
@@ -419,7 +430,7 @@
library.importUri.scheme == 'package');
}
- await dataComputer.inspectComponent(component);
+ await dataComputer.inspectTestResultData(testResultData);
for (Library library in component.libraries) {
if (excludeLibrary(library) &&
@@ -427,7 +438,7 @@
continue;
}
dataComputer.computeLibraryData(
- config, compilerResult, library, actualMapFor(library));
+ testResultData, library, actualMapFor(library));
for (Class cls in library.classes) {
processClass(cls, actualMapFor(cls));
for (Member member in cls.members) {
diff --git a/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart b/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
index 76f3281..9110735 100644
--- a/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
+++ b/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
@@ -34,24 +34,18 @@
///
/// Fills [actualMap] with the data.
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new InheritanceDataExtractor(compilerResult, actualMap)
+ new InheritanceDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new InheritanceDataExtractor(compilerResult, actualMap)
+ new InheritanceDataExtractor(testResultData.compilerResult, actualMap)
.computeForClass(cls);
}
@@ -59,8 +53,8 @@
bool get supportsErrors => true;
@override
- Features? computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ Features? computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
return null; //errorsToText(errors, useCodes: true);
}
diff --git a/pkg/front_end/test/covariance_check/covariance_check_test.dart b/pkg/front_end/test/covariance_check/covariance_check_test.dart
index c91c012..074088c 100644
--- a/pkg/front_end/test/covariance_check/covariance_check_test.dart
+++ b/pkg/front_end/test/covariance_check/covariance_check_test.dart
@@ -26,24 +26,19 @@
///
/// Fills [actualMap] with the data.
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new CovarianceCheckDataExtractor(compilerResult, actualMap)
+ new CovarianceCheckDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- member.accept(new CovarianceCheckDataExtractor(compilerResult, actualMap));
+ member.accept(new CovarianceCheckDataExtractor(
+ testResultData.compilerResult, actualMap));
}
@override
diff --git a/pkg/front_end/test/extensions/extensions_test.dart b/pkg/front_end/test/extensions/extensions_test.dart
index 83e5bbf..bb09833 100644
--- a/pkg/front_end/test/extensions/extensions_test.dart
+++ b/pkg/front_end/test/extensions/extensions_test.dart
@@ -38,44 +38,34 @@
const ExtensionsDataComputer();
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- member.accept(new ExtensionsDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new ExtensionsDataExtractor(testResultData.compilerResult, actualMap));
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new ExtensionsDataExtractor(compilerResult, actualMap).computeForClass(cls);
+ new ExtensionsDataExtractor(testResultData.compilerResult, actualMap)
+ .computeForClass(cls);
}
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new ExtensionsDataExtractor(compilerResult, actualMap)
+ new ExtensionsDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@override
- void computeExtensionData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Extension extension,
+ void computeExtensionData(TestResultData testResultData, Extension extension,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new ExtensionsDataExtractor(compilerResult, actualMap)
+ new ExtensionsDataExtractor(testResultData.compilerResult, actualMap)
.computeForExtension(extension);
}
@@ -83,8 +73,8 @@
bool get supportsErrors => true;
@override
- Features computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ Features computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
Features features = new Features();
for (FormattedMessage error in errors) {
if (error.problemMessage.contains(',')) {
diff --git a/pkg/front_end/test/id_testing/id_testing_test.dart b/pkg/front_end/test/id_testing/id_testing_test.dart
index e8f9f5f..676b6df 100644
--- a/pkg/front_end/test/id_testing/id_testing_test.dart
+++ b/pkg/front_end/test/id_testing/id_testing_test.dart
@@ -2,19 +2,20 @@
// 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 'dart:io' show Directory, Platform;
+
import 'package:_fe_analyzer_shared/src/testing/id.dart' show ActualData, Id;
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart'
show DataInterpreter, StringDataInterpreter, runTests;
-import 'dart:io' show Directory, Platform;
import 'package:front_end/src/fasta/messages.dart' show FormattedMessage;
import 'package:front_end/src/testing/id_testing_helper.dart'
show
CfeDataExtractor,
- InternalCompilerResult,
DataComputer,
- TestConfig,
- defaultCfeConfig,
+ InternalCompilerResult,
+ TestResultData,
createUriForFileName,
+ defaultCfeConfig,
onFailure,
runTestFor;
import 'package:front_end/src/testing/id_testing_utils.dart';
@@ -40,33 +41,26 @@
const IdTestingDataComputer();
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- member.accept(new IdTestingDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new IdTestingDataExtractor(testResultData.compilerResult, actualMap));
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new IdTestingDataExtractor(compilerResult, actualMap).computeForClass(cls);
+ new IdTestingDataExtractor(testResultData.compilerResult, actualMap)
+ .computeForClass(cls);
}
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new IdTestingDataExtractor(compilerResult, actualMap)
+ new IdTestingDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@@ -74,8 +68,8 @@
bool get supportsErrors => true;
@override
- String computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ String computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
return errorsToText(errors);
}
diff --git a/pkg/front_end/test/id_tests/assigned_variables_test.dart b/pkg/front_end/test/id_tests/assigned_variables_test.dart
index 1741638..23a5b09 100644
--- a/pkg/front_end/test/id_tests/assigned_variables_test.dart
+++ b/pkg/front_end/test/id_tests/assigned_variables_test.dart
@@ -38,20 +38,18 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<_Data>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
AssignedVariablesForTesting<TreeNode, VariableDeclaration>?
assignedVariables = memberBuilder
.dataForTesting!.inferenceData.flowAnalysisResult.assignedVariables;
if (assignedVariables == null) return;
member.accept(new AssignedVariablesDataExtractor(
- compilerResult, actualMap, assignedVariables));
+ testResultData.compilerResult, actualMap, assignedVariables));
}
}
diff --git a/pkg/front_end/test/id_tests/constant_test.dart b/pkg/front_end/test/id_tests/constant_test.dart
index bcee3af..2d48d62 100644
--- a/pkg/front_end/test/id_tests/constant_test.dart
+++ b/pkg/front_end/test/id_tests/constant_test.dart
@@ -9,10 +9,10 @@
import 'package:front_end/src/testing/id_testing_helper.dart'
show
CfeDataExtractor,
- InternalCompilerResult,
DataComputer,
FormattedMessage,
- TestConfig,
+ InternalCompilerResult,
+ TestResultData,
createUriForFileName,
defaultCfeConfig,
onFailure,
@@ -34,23 +34,19 @@
const ConstantsDataComputer();
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- member.accept(new ConstantsDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new ConstantsDataExtractor(testResultData.compilerResult, actualMap));
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new ConstantsDataExtractor(compilerResult, actualMap).computeForClass(cls);
+ new ConstantsDataExtractor(testResultData.compilerResult, actualMap)
+ .computeForClass(cls);
}
@override
@@ -58,8 +54,8 @@
/// Returns data corresponding to [error].
@override
- String computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ String computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
return errorsToText(errors);
}
diff --git a/pkg/front_end/test/id_tests/definite_assignment_test.dart b/pkg/front_end/test/id_tests/definite_assignment_test.dart
index b4112f5..bc19b2b 100644
--- a/pkg/front_end/test/id_tests/definite_assignment_test.dart
+++ b/pkg/front_end/test/id_tests/definite_assignment_test.dart
@@ -35,15 +35,15 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
- member.accept(new DefiniteAssignmentDataExtractor(compilerResult, actualMap,
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
+ member.accept(new DefiniteAssignmentDataExtractor(
+ testResultData.compilerResult,
+ actualMap,
memberBuilder.dataForTesting!.inferenceData.flowAnalysisResult));
}
diff --git a/pkg/front_end/test/id_tests/definite_unassignment_test.dart b/pkg/front_end/test/id_tests/definite_unassignment_test.dart
index d51a02e..3a26b89 100644
--- a/pkg/front_end/test/id_tests/definite_unassignment_test.dart
+++ b/pkg/front_end/test/id_tests/definite_unassignment_test.dart
@@ -35,16 +35,14 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
member.accept(new DefiniteUnassignmentDataExtractor(
- compilerResult,
+ testResultData.compilerResult,
actualMap,
memberBuilder.dataForTesting!.inferenceData.flowAnalysisResult));
}
diff --git a/pkg/front_end/test/id_tests/inferred_type_arguments_test.dart b/pkg/front_end/test/id_tests/inferred_type_arguments_test.dart
index ef7a1ca..7e8b426 100644
--- a/pkg/front_end/test/id_tests/inferred_type_arguments_test.dart
+++ b/pkg/front_end/test/id_tests/inferred_type_arguments_test.dart
@@ -39,16 +39,14 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<List<DartType>>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
member.accept(new InferredTypeArgumentDataExtractor(
- compilerResult,
+ testResultData.compilerResult,
memberBuilder.dataForTesting!.inferenceData.typeInferenceResult,
actualMap));
}
diff --git a/pkg/front_end/test/id_tests/inferred_variable_types_test.dart b/pkg/front_end/test/id_tests/inferred_variable_types_test.dart
index 02c50fa..6882661 100644
--- a/pkg/front_end/test/id_tests/inferred_variable_types_test.dart
+++ b/pkg/front_end/test/id_tests/inferred_variable_types_test.dart
@@ -39,16 +39,14 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<DartType>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
member.accept(new InferredTypeArgumentDataExtractor(
- compilerResult,
+ testResultData.compilerResult,
memberBuilder.dataForTesting!.inferenceData.typeInferenceResult,
actualMap));
}
diff --git a/pkg/front_end/test/id_tests/inheritance_test.dart b/pkg/front_end/test/id_tests/inheritance_test.dart
index 78f9bf5..b618894 100644
--- a/pkg/front_end/test/id_tests/inheritance_test.dart
+++ b/pkg/front_end/test/id_tests/inheritance_test.dart
@@ -49,24 +49,18 @@
///
/// Fills [actualMap] with the data.
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new InheritanceDataExtractor(config, compilerResult, actualMap)
+ new InheritanceDataExtractor(testResultData, actualMap)
.computeForLibrary(library);
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new InheritanceDataExtractor(config, compilerResult, actualMap)
+ new InheritanceDataExtractor(testResultData, actualMap)
.computeForClass(cls);
}
@@ -74,8 +68,8 @@
bool get supportsErrors => true;
@override
- String computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ String computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
return errorsToText(errors, useCodes: true);
}
@@ -84,12 +78,15 @@
}
class InheritanceDataExtractor extends CfeDataExtractor<String> {
- final TestConfig _config;
- final InternalCompilerResult _compilerResult;
+ final TestResultData _testResultData;
InheritanceDataExtractor(
- this._config, this._compilerResult, Map<Id, ActualData<String>> actualMap)
- : super(_compilerResult, actualMap);
+ this._testResultData, Map<Id, ActualData<String>> actualMap)
+ : super(_testResultData.compilerResult, actualMap);
+
+ TestConfig get _config => _testResultData.config;
+
+ InternalCompilerResult get _compilerResult => _testResultData.compilerResult;
ClassHierarchy get _hierarchy => _compilerResult.classHierarchy!;
diff --git a/pkg/front_end/test/id_tests/nullability_test.dart b/pkg/front_end/test/id_tests/nullability_test.dart
index 0ffa7f2..e563f8d 100644
--- a/pkg/front_end/test/id_tests/nullability_test.dart
+++ b/pkg/front_end/test/id_tests/nullability_test.dart
@@ -29,13 +29,11 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- member.accept(new NullabilityDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new NullabilityDataExtractor(testResultData.compilerResult, actualMap));
}
}
diff --git a/pkg/front_end/test/id_tests/reachability_test.dart b/pkg/front_end/test/id_tests/reachability_test.dart
index a2e6a1a..6a043b4 100644
--- a/pkg/front_end/test/id_tests/reachability_test.dart
+++ b/pkg/front_end/test/id_tests/reachability_test.dart
@@ -37,15 +37,15 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<Set<_ReachabilityAssertion>>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
- member.accept(new ReachabilityDataExtractor(compilerResult, actualMap,
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
+ member.accept(new ReachabilityDataExtractor(
+ testResultData.compilerResult,
+ actualMap,
memberBuilder.dataForTesting!.inferenceData.flowAnalysisResult));
}
diff --git a/pkg/front_end/test/id_tests/type_promotion_test.dart b/pkg/front_end/test/id_tests/type_promotion_test.dart
index 6aae1e8..59cc18e6 100644
--- a/pkg/front_end/test/id_tests/type_promotion_test.dart
+++ b/pkg/front_end/test/id_tests/type_promotion_test.dart
@@ -33,13 +33,11 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<DartType>> actualMap,
{bool? verbose}) {
- member.accept(new TypePromotionDataExtractor(compilerResult, actualMap));
+ member.accept(new TypePromotionDataExtractor(
+ testResultData.compilerResult, actualMap));
}
}
diff --git a/pkg/front_end/test/id_tests/why_not_promoted_test.dart b/pkg/front_end/test/id_tests/why_not_promoted_test.dart
index 4362bf9..0d52a11 100644
--- a/pkg/front_end/test/id_tests/why_not_promoted_test.dart
+++ b/pkg/front_end/test/id_tests/why_not_promoted_test.dart
@@ -41,15 +41,15 @@
///
/// Fills [actualMap] with the data.
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
SourceMemberBuilder memberBuilder =
- lookupMemberBuilder(compilerResult, member) as SourceMemberBuilder;
- member.accept(new WhyNotPromotedDataExtractor(compilerResult, actualMap,
+ lookupMemberBuilder(testResultData.compilerResult, member)
+ as SourceMemberBuilder;
+ member.accept(new WhyNotPromotedDataExtractor(
+ testResultData.compilerResult,
+ actualMap,
memberBuilder.dataForTesting!.inferenceData.flowAnalysisResult));
}
}
diff --git a/pkg/front_end/test/language_versioning/language_versioning_test.dart b/pkg/front_end/test/language_versioning/language_versioning_test.dart
index 221ce79..5e88669 100644
--- a/pkg/front_end/test/language_versioning/language_versioning_test.dart
+++ b/pkg/front_end/test/language_versioning/language_versioning_test.dart
@@ -17,6 +17,7 @@
DataComputer,
InternalCompilerResult,
TestConfig,
+ TestResultData,
createUriForFileName,
onFailure,
runTestFor;
@@ -42,16 +43,13 @@
]);
}
-// Ugly hack.
-late CompilerOptions stashedOptions;
-
class TestConfigWithLanguageVersion extends TestConfig {
TestConfigWithLanguageVersion(String marker, String name)
: super(marker, name);
@override
- void customizeCompilerOptions(CompilerOptions options, TestData testData) {
- stashedOptions = options;
+ CompilerOptions customizeCompilerOptions(
+ CompilerOptions options, TestData testData) {
options.currentSdkVersion = "2.8";
File f = new File.fromUri(testData.testFileUri.resolve("test.options"));
@@ -69,6 +67,7 @@
}
}
}
+ return options;
}
}
@@ -82,15 +81,15 @@
const LanguageVersioningDataComputer();
@override
- Future<void> inspectComponent(Component component) async {
+ Future<void> inspectTestResultData(TestResultData testResultData) async {
+ CompilerOptions options = testResultData.customData;
+ Component component = testResultData.compilerResult.component!;
for (Library library in component.libraries) {
if (library.importUri.scheme == "dart") continue;
Version lvFile =
- (await lv.languageVersionForUri(library.fileUri, stashedOptions))
- .version;
+ (await lv.languageVersionForUri(library.fileUri, options)).version;
Version lvImportUri =
- (await lv.languageVersionForUri(library.importUri, stashedOptions))
- .version;
+ (await lv.languageVersionForUri(library.importUri, options)).version;
if ((lvFile != lvImportUri || lvFile != library.languageVersion)) {
throw """
Language version disagreement:
@@ -103,13 +102,11 @@
}
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new LanguageVersioningDataExtractor(compilerResult, actualMap)
+ new LanguageVersioningDataExtractor(
+ testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@@ -117,8 +114,8 @@
bool get supportsErrors => true;
@override
- Features computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ Features computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
Features features = new Features();
features[Tags.errors] = errors.map((m) => m.code.name).join(',');
return features;
diff --git a/pkg/front_end/test/macros/macro_test.dart b/pkg/front_end/test/macros/macro_test.dart
index ee92293..463b0cf 100644
--- a/pkg/front_end/test/macros/macro_test.dart
+++ b/pkg/front_end/test/macros/macro_test.dart
@@ -34,33 +34,24 @@
const MacroDataComputer();
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- member.accept(new MacroDataExtractor(compilerResult, actualMap));
+ member.accept(new MacroDataExtractor(testResultData, actualMap));
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new MacroDataExtractor(compilerResult, actualMap).computeForClass(cls);
+ new MacroDataExtractor(testResultData, actualMap).computeForClass(cls);
}
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new MacroDataExtractor(compilerResult, actualMap)
+ new MacroDataExtractor(testResultData, actualMap)
.computeForLibrary(library);
}
@@ -75,6 +66,8 @@
static const String compilationSequence = 'compilationSequence';
static const String declaredMacros = 'declaredMacros';
static const String appliedMacros = 'appliedMacros';
+ static const String macroClassIds = 'macroClassIds';
+ static const String macroInstanceIds = 'macroInstanceIds';
}
String importUriToString(Uri importUri) {
@@ -96,16 +89,17 @@
}
class MacroDataExtractor extends CfeDataExtractor<Features> {
+ final TestResultData testResultData;
late final MacroDeclarationData macroDeclarationData;
late final MacroApplicationData macroApplicationData;
- MacroDataExtractor(InternalCompilerResult compilerResult,
- Map<Id, ActualData<Features>> actualMap)
- : super(compilerResult, actualMap) {
- macroDeclarationData = compilerResult
- .kernelTargetForTesting!.loader.dataForTesting!.macroDeclarationData;
- macroApplicationData = compilerResult
- .kernelTargetForTesting!.loader.dataForTesting!.macroApplicationData;
+ MacroDataExtractor(
+ this.testResultData, Map<Id, ActualData<Features>> actualMap)
+ : super(testResultData.compilerResult, actualMap) {
+ macroDeclarationData = testResultData.compilerResult.kernelTargetForTesting!
+ .loader.dataForTesting!.macroDeclarationData;
+ macroApplicationData = testResultData.compilerResult.kernelTargetForTesting!
+ .loader.dataForTesting!.macroApplicationData;
}
LibraryMacroApplicationData? getLibraryMacroApplicationData(Library library) {
diff --git a/pkg/front_end/test/patching/patching_test.dart b/pkg/front_end/test/patching/patching_test.dart
index 6f237db..a3b4829 100644
--- a/pkg/front_end/test/patching/patching_test.dart
+++ b/pkg/front_end/test/patching/patching_test.dart
@@ -65,33 +65,26 @@
const PatchingDataComputer();
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- member.accept(new PatchingDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new PatchingDataExtractor(testResultData.compilerResult, actualMap));
}
@override
- void computeClassData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Class cls,
+ void computeClassData(TestResultData testResultData, Class cls,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new PatchingDataExtractor(compilerResult, actualMap).computeForClass(cls);
+ new PatchingDataExtractor(testResultData.compilerResult, actualMap)
+ .computeForClass(cls);
}
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new PatchingDataExtractor(compilerResult, actualMap)
+ new PatchingDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@@ -99,8 +92,8 @@
bool get supportsErrors => true;
@override
- Features computeErrorData(TestConfig config, InternalCompilerResult compiler,
- Id id, List<FormattedMessage> errors) {
+ Features computeErrorData(
+ TestResultData testResultData, Id id, List<FormattedMessage> errors) {
Features features = new Features();
features[Tags.error] = errorsToText(errors);
return features;
diff --git a/pkg/front_end/test/predicates/predicate_test.dart b/pkg/front_end/test/predicates/predicate_test.dart
index 5866119..2ffdc45 100644
--- a/pkg/front_end/test/predicates/predicate_test.dart
+++ b/pkg/front_end/test/predicates/predicate_test.dart
@@ -78,24 +78,19 @@
///
/// Fills [actualMap] with the data.
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- new PredicateDataExtractor(compilerResult, actualMap)
+ new PredicateDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
- member.accept(new PredicateDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new PredicateDataExtractor(testResultData.compilerResult, actualMap));
}
@override
diff --git a/pkg/front_end/test/static_types/static_type_test.dart b/pkg/front_end/test/static_types/static_type_test.dart
index cf4d5c3..80a339d 100644
--- a/pkg/front_end/test/static_types/static_type_test.dart
+++ b/pkg/front_end/test/static_types/static_type_test.dart
@@ -39,24 +39,19 @@
///
/// Fills [actualMap] with the data.
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new StaticTypeDataExtractor(compilerResult, actualMap)
+ new StaticTypeDataExtractor(testResultData.compilerResult, actualMap)
.computeForLibrary(library);
}
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- member.accept(new StaticTypeDataExtractor(compilerResult, actualMap));
+ member.accept(
+ new StaticTypeDataExtractor(testResultData.compilerResult, actualMap));
}
@override
diff --git a/pkg/front_end/test/text_representation/text_representation_test.dart b/pkg/front_end/test/text_representation/text_representation_test.dart
index b29f7ac..24e5246 100644
--- a/pkg/front_end/test/text_representation/text_representation_test.dart
+++ b/pkg/front_end/test/text_representation/text_representation_test.dart
@@ -96,26 +96,22 @@
const TextRepresentationDataComputer();
@override
- void computeLibraryData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Library library,
+ void computeLibraryData(TestResultData testResultData, Library library,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
- new TextRepresentationDataExtractor(
- compilerResult, actualMap, getStrategy(config.marker))
+ new TextRepresentationDataExtractor(testResultData.compilerResult,
+ actualMap, getStrategy(testResultData.config.marker))
.computeForLibrary(library);
}
@override
- void computeMemberData(
- TestConfig config,
- InternalCompilerResult compilerResult,
- Member member,
+ void computeMemberData(TestResultData testResultData, Member member,
Map<Id, ActualData<String>> actualMap,
{bool? verbose}) {
member.accept(new TextRepresentationDataExtractor(
- compilerResult, actualMap, getStrategy(config.marker)));
+ testResultData.compilerResult,
+ actualMap,
+ getStrategy(testResultData.config.marker)));
}
@override
diff --git a/tools/VERSION b/tools/VERSION
index e94eb46..f35e17b 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 145
+PRERELEASE 146
PRERELEASE_PATCH 0
\ No newline at end of file