Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8fd5a04

Browse files
author
Dart CI
committed
Version 2.16.0-152.0.dev
Merge commit '2766add19a274cef9eb0c763fa3627026fd9b923' into 'dev'
2 parents 8bd47ff + 2766add commit 8fd5a04

34 files changed

+703
-558
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/type_info.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ TypeInfo computeType(final Token token, bool required,
251251

252252
assert(typeParamOrArg == noTypeParamOrArg);
253253
next = next.next!;
254+
255+
// TODO(scheglov) This is a hack to partially fix.
256+
// https://github.com/dart-lang/sdk/issues/47951
257+
if (optional('?', next) &&
258+
optional('super', next.next!) &&
259+
optional('.', next.next!.next!)) {
260+
return simpleNullableType;
261+
}
262+
if (optional('super', next) && optional('.', next.next!)) {
263+
return simpleType;
264+
}
265+
254266
if (optional('.', next)) {
255267
next = next.next!;
256268
if (isValidTypeReference(next)) {

pkg/analyzer/lib/src/summary2/informative_data.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,9 @@ class _InformativeDataWriter {
13701370
} else if (notDefault is FunctionTypedFormalParameter) {
13711371
_writeTypeParameters(notDefault.typeParameters);
13721372
_writeFormalParameters(notDefault.parameters);
1373+
} else if (notDefault is SuperFormalParameter) {
1374+
_writeTypeParameters(notDefault.typeParameters);
1375+
_writeFormalParameters(notDefault.parameters);
13731376
} else {
13741377
_writeTypeParameters(null);
13751378
_writeFormalParameters(null);

pkg/analyzer/test/generated/utilities_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,6 @@ class A {
16441644
);
16451645
}
16461646

1647-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/47951')
16481647
void test_superFormalParameter() {
16491648
var findNode = _parseStringToFindNode(r'''
16501649
class A {
@@ -1666,7 +1665,6 @@ class B extends A {
16661665
);
16671666
}
16681667

1669-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/47741')
16701668
void test_superFormalParameter_functionTyped() {
16711669
var findNode = _parseStringToFindNode(r'''
16721670
class A {

pkg/analyzer/test/src/summary/resynthesize_common.dart

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,6 @@ library
14531453
''');
14541454
}
14551455

1456-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/47951')
14571456
test_class_constructor_parameters_super_explicitType_function() async {
14581457
var library = await checkLibrary('''
14591458
class A {
@@ -1492,7 +1491,6 @@ library
14921491
''');
14931492
}
14941493

1495-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/47951')
14961494
test_class_constructor_parameters_super_explicitType_interface() async {
14971495
var library = await checkLibrary('''
14981496
class A {
@@ -1518,13 +1516,45 @@ library
15181516
constructors
15191517
@47
15201518
parameters
1521-
requiredPositional final super.a @49
1519+
requiredPositional final super.a @59
15221520
type: int
15231521
superConstructorParameter: a@18
15241522
superConstructor: self::@class::A::@constructor::•
15251523
''');
15261524
}
15271525

1526+
test_class_constructor_parameters_super_explicitType_interface_nullable() async {
1527+
var library = await checkLibrary('''
1528+
class A {
1529+
A(num? a);
1530+
}
1531+
1532+
class B extends A {
1533+
B(int? super.a);
1534+
}
1535+
''');
1536+
checkElementText(library, r'''
1537+
library
1538+
definingUnit
1539+
classes
1540+
class A @6
1541+
constructors
1542+
@12
1543+
parameters
1544+
requiredPositional a @19
1545+
type: num?
1546+
class B @32
1547+
supertype: A
1548+
constructors
1549+
@48
1550+
parameters
1551+
requiredPositional final super.a @61
1552+
type: int?
1553+
superConstructorParameter: a@19
1554+
superConstructor: self::@class::A::@constructor::•
1555+
''');
1556+
}
1557+
15281558
test_class_constructor_parameters_super_invalid_topFunction() async {
15291559
var library = await checkLibrary('''
15301560
void f(super.a) {}

pkg/front_end/lib/src/fasta/builder/class_builder.dart

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ import '../modifier.dart';
3939
import '../names.dart' show noSuchMethodName;
4040
import '../problems.dart' show internalProblem, unhandled;
4141
import '../scope.dart';
42-
import '../source/source_constructor_builder.dart';
4342
import '../source/source_factory_builder.dart';
4443
import '../source/source_library_builder.dart' show SourceLibraryBuilder;
4544
import '../source/source_loader.dart';
4645
import '../source/source_member_builder.dart';
4746
import '../type_inference/type_schema.dart' show UnknownType;
4847
import '../util/helpers.dart' show DelayedActionPerformer;
4948
import 'builder.dart';
50-
import 'constructor_builder.dart';
5149
import 'constructor_reference_builder.dart';
5250
import 'declaration_builder.dart';
53-
import 'field_builder.dart';
5451
import 'function_builder.dart';
5552
import 'library_builder.dart';
5653
import 'member_builder.dart';
@@ -89,8 +86,6 @@ abstract class ClassBuilder implements DeclarationBuilder {
8986
@override
9087
Uri get fileUri;
9188

92-
ClassBuilder? get patchForTesting;
93-
9489
bool get isAbstract;
9590

9691
bool get isMacro;
@@ -120,13 +115,6 @@ abstract class ClassBuilder implements DeclarationBuilder {
120115

121116
void forEach(void f(String name, Builder builder));
122117

123-
void forEachDeclaredField(
124-
void Function(String name, FieldBuilder fieldBuilder) f);
125-
126-
void forEachDeclaredConstructor(
127-
void Function(String name, ConstructorBuilder constructorBuilder)
128-
callback);
129-
130118
/// The [Class] built by this builder.
131119
///
132120
/// For a patch class the origin class is returned.
@@ -258,17 +246,13 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
258246
@override
259247
ClassBuilder? actualOrigin;
260248

261-
@override
262-
ClassBuilder? get patchForTesting => _patchBuilder;
263-
264249
@override
265250
bool isNullClass = false;
266251

267252
InterfaceType? _legacyRawType;
268253
InterfaceType? _nullableRawType;
269254
InterfaceType? _nonNullableRawType;
270255
InterfaceType? _thisType;
271-
ClassBuilder? _patchBuilder;
272256

273257
ClassBuilderImpl(
274258
List<MetadataBuilder>? metadata,
@@ -319,14 +303,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
319303
includeInjectedConstructors: includeInjectedConstructors);
320304
} else {
321305
constructors.forEach(f);
322-
if (includeInjectedConstructors) {
323-
_patchBuilder?.constructors
324-
.forEach((String name, MemberBuilder builder) {
325-
if (!builder.isPatch) {
326-
f(name, builder);
327-
}
328-
});
329-
}
330306
}
331307
}
332308

@@ -415,57 +391,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
415391
scope.forEach(f);
416392
}
417393

418-
@override
419-
void forEachDeclaredField(
420-
void Function(String name, FieldBuilder fieldBuilder) callback) {
421-
void callbackFilteringFieldBuilders(String name, Builder builder) {
422-
if (builder is FieldBuilder) {
423-
callback(name, builder);
424-
}
425-
}
426-
427-
// Currently, fields can't be patched, but can be injected. When the fields
428-
// will be made available for patching, the following code should iterate
429-
// first over the fields from the patch and then -- over the fields in the
430-
// original declaration, filtering out the patched fields. For now, the
431-
// assert checks that the names of the fields from the original declaration
432-
// and from the patch don't intersect.
433-
assert(
434-
_patchBuilder == null ||
435-
_patchBuilder!.scope.localMembers
436-
.where((b) => b is FieldBuilder)
437-
.map((b) => (b as FieldBuilder).name)
438-
.toSet()
439-
.intersection(scope.localMembers
440-
.where((b) => b is FieldBuilder)
441-
.map((b) => (b as FieldBuilder).name)
442-
.toSet())
443-
.isEmpty,
444-
"Detected an attempt to patch a field.");
445-
_patchBuilder?.scope.forEach(callbackFilteringFieldBuilders);
446-
scope.forEach(callbackFilteringFieldBuilders);
447-
}
448-
449-
@override
450-
void forEachDeclaredConstructor(
451-
void Function(
452-
String name, DeclaredSourceConstructorBuilder constructorBuilder)
453-
callback) {
454-
Set<String> visitedConstructorNames = {};
455-
void callbackFilteringFieldBuilders(String name, Builder builder) {
456-
if (builder is DeclaredSourceConstructorBuilder &&
457-
visitedConstructorNames.add(builder.name)) {
458-
callback(name, builder);
459-
}
460-
}
461-
462-
// Constructors can be patched, so iterate first over constructors in the
463-
// patch, and then over constructors in the original declaration skipping
464-
// those with the names that are in the patch.
465-
_patchBuilder?.constructors.forEach(callbackFilteringFieldBuilders);
466-
constructors.forEach(callbackFilteringFieldBuilders);
467-
}
468-
469394
@override
470395
Builder? lookupLocalMember(String name,
471396
{bool setter: false, bool required: false}) {
@@ -818,55 +743,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
818743
}
819744
}
820745

821-
@override
822-
void applyPatch(Builder patch) {
823-
if (patch is ClassBuilder) {
824-
patch.actualOrigin = this;
825-
_patchBuilder = patch;
826-
// TODO(ahe): Complain if `patch.supertype` isn't null.
827-
scope.forEachLocalMember((String name, Builder member) {
828-
Builder? memberPatch =
829-
patch.scope.lookupLocalMember(name, setter: false);
830-
if (memberPatch != null) {
831-
member.applyPatch(memberPatch);
832-
}
833-
});
834-
scope.forEachLocalSetter((String name, Builder member) {
835-
Builder? memberPatch =
836-
patch.scope.lookupLocalMember(name, setter: true);
837-
if (memberPatch != null) {
838-
member.applyPatch(memberPatch);
839-
}
840-
});
841-
constructors.local.forEach((String name, Builder member) {
842-
Builder? memberPatch = patch.constructors.local[name];
843-
if (memberPatch != null) {
844-
member.applyPatch(memberPatch);
845-
}
846-
});
847-
848-
int originLength = typeVariables?.length ?? 0;
849-
int patchLength = patch.typeVariables?.length ?? 0;
850-
if (originLength != patchLength) {
851-
patch.addProblem(messagePatchClassTypeVariablesMismatch,
852-
patch.charOffset, noLength, context: [
853-
messagePatchClassOrigin.withLocation(fileUri, charOffset, noLength)
854-
]);
855-
} else if (typeVariables != null) {
856-
int count = 0;
857-
for (TypeVariableBuilder t in patch.typeVariables!) {
858-
typeVariables![count++].applyPatch(t);
859-
}
860-
}
861-
} else {
862-
library.addProblem(messagePatchDeclarationMismatch, patch.charOffset,
863-
noLength, patch.fileUri, context: [
864-
messagePatchDeclarationOrigin.withLocation(
865-
fileUri, charOffset, noLength)
866-
]);
867-
}
868-
}
869-
870746
@override
871747
FunctionType? computeRedirecteeType(
872748
RedirectingFactoryBuilder factory, TypeEnvironment typeEnvironment) {

pkg/front_end/lib/src/fasta/builder/field_builder.dart

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,9 @@
55
library fasta.field_builder;
66

77
import 'package:kernel/ast.dart';
8-
import 'package:kernel/core_types.dart';
98

109
import 'member_builder.dart';
11-
import 'metadata_builder.dart';
12-
import 'type_builder.dart';
1310

1411
abstract class FieldBuilder implements MemberBuilder {
1512
Field get field;
16-
17-
List<MetadataBuilder>? get metadata;
18-
19-
TypeBuilder? get type;
20-
21-
bool get isCovariantByDeclaration;
22-
23-
bool get isLate;
24-
25-
bool get hasInitializer;
26-
27-
/// Whether the body of this field has been built.
28-
///
29-
/// Constant fields have their initializer built in the outline so we avoid
30-
/// building them twice as part of the non-outline build.
31-
bool get hasBodyBeenBuilt;
32-
33-
/// Builds the body of this field using [initializer] as the initializer
34-
/// expression.
35-
void buildBody(CoreTypes coreTypes, Expression? initializer);
36-
37-
/// Builds the field initializers for each field used to encode this field
38-
/// using the [fileOffset] for the created nodes and [value] as the initial
39-
/// field value.
40-
List<Initializer> buildInitializer(int fileOffset, Expression value,
41-
{required bool isSynthetic});
42-
43-
bool get isEligibleForInference;
44-
45-
DartType get builtType;
46-
47-
DartType inferType();
48-
49-
DartType get fieldType;
5013
}

pkg/front_end/lib/src/fasta/builder/formal_parameter_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import '../kernel/internal_ast.dart' show VariableDeclarationImpl;
2222
import '../modifier.dart';
2323
import '../scope.dart' show Scope;
2424
import '../source/source_factory_builder.dart';
25+
import '../source/source_field_builder.dart';
2526
import '../source/source_library_builder.dart';
2627
import '../util/helpers.dart' show DelayedActionPerformer;
2728
import 'builder.dart';
2829
import 'class_builder.dart';
2930
import 'constructor_builder.dart';
30-
import 'field_builder.dart';
3131
import 'library_builder.dart';
3232
import 'metadata_builder.dart';
3333
import 'modifier_builder.dart';
@@ -197,7 +197,7 @@ class FormalParameterBuilder extends ModifierBuilderImpl
197197

198198
void finalizeInitializingFormal(ClassBuilder classBuilder) {
199199
Builder? fieldBuilder = classBuilder.lookupLocalMember(name);
200-
if (fieldBuilder is FieldBuilder) {
200+
if (fieldBuilder is SourceFieldBuilder) {
201201
variable!.type = fieldBuilder.inferType();
202202
} else {
203203
variable!.type = const DynamicType();

pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:kernel/ast.dart'
99

1010
import '../builder/builder.dart';
1111
import '../builder/constructor_builder.dart';
12+
import '../builder/field_builder.dart';
1213
import '../builder/member_builder.dart';
1314

1415
import '../builder/procedure_builder.dart';
@@ -89,7 +90,8 @@ abstract class DillMemberBuilder extends MemberBuilderImpl {
8990
: const <ClassMember>[];
9091
}
9192

92-
class DillFieldBuilder extends DillMemberBuilder {
93+
class DillFieldBuilder extends DillMemberBuilder implements FieldBuilder {
94+
@override
9395
final Field field;
9496

9597
DillFieldBuilder(this.field, Builder parent) : super(field, parent);

0 commit comments

Comments
 (0)