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

Commit 6f5478a

Browse files
author
Dart CI
committed
Version 2.19.0-398.0.dev
Merge 933cba6 into dev
2 parents 3169876 + 933cba6 commit 6f5478a

File tree

45 files changed

+1925
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1925
-156
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9304,7 +9304,7 @@ class Parser {
93049304
// TODO(paulberry): Make sure OTHER_IDENTIFIER is handled
93059305
// TODO(paulberry): Technically `dynamic` is valid for
93069306
// `typeIdentifier`--file an issue
9307-
if (isValidNonRecordTypeReference(next)) {
9307+
if (next.isIdentifier) {
93089308
Token beforeFirstIdentifier = token;
93099309
Token firstIdentifier = token = next;
93109310
next = token.next!;
@@ -9313,7 +9313,7 @@ class Parser {
93139313
if (optional('.', next)) {
93149314
dot = token = next;
93159315
next = token.next!;
9316-
if (isValidNonRecordTypeReference(next)) {
9316+
if (next.isIdentifier) {
93179317
secondIdentifier = token = next;
93189318
// TODO(paulberry): grammar specifies
93199319
// `typeIdentifier | qualifiedName`, but that permits `a.b.c`,

pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,14 @@ mixin TypeAnalyzer<
360360
/// the expression, [pattern] for the pattern to match, [ifTrue] for the
361361
/// "then" branch, and [ifFalse] for the "else" branch (if present).
362362
///
363+
/// Returns the static type of [expression].
364+
///
363365
/// Stack effect: pushes (Expression scrutinee, Pattern, Expression guard,
364366
/// Statement ifTrue, Statement ifFalse). If there is no `else` clause, the
365367
/// representation for `ifFalse` will be pushed by [handleNoStatement]. If
366368
/// there is no guard, the representation for `guard` will be pushed by
367369
/// [handleNoGuard].
368-
void analyzeIfCaseStatement(
370+
Type analyzeIfCaseStatement(
369371
Statement node,
370372
Expression expression,
371373
Pattern pattern,
@@ -391,6 +393,7 @@ mixin TypeAnalyzer<
391393
// Stack: (Expression, Pattern, Guard)
392394
flow?.ifStatement_thenBegin(null, node);
393395
_analyzeIfCommon(node, ifTrue, ifFalse);
396+
return initializerType;
394397
}
395398

396399
/// Analyzes a collection element of the form `if (condition) ifTrue` or
@@ -1062,6 +1065,8 @@ mixin TypeAnalyzer<
10621065
/// If this is a wildcard pattern (it doesn't bind any variable), [variable]
10631066
/// should be `null`.
10641067
///
1068+
/// Returns the static type of the variable (possibly inferred).
1069+
///
10651070
/// Stack effect: none.
10661071
Type analyzeVariablePattern(
10671072
Type matchedType,

pkg/_fe_analyzer_shared/test/mini_ast.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,8 @@ class _CheckAssigned extends Statement {
15051505

15061506
@override
15071507
void visit(Harness h) {
1508-
expect(h.flow.isAssigned(variable), expectedAssignedState);
1508+
expect(h.flow.isAssigned(variable), expectedAssignedState,
1509+
reason: 'at $location');
15091510
h.irBuilder.atom('null', Kind.statement, location: location);
15101511
}
15111512
}

pkg/analyzer/lib/src/error/use_result_verifier.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class UseResultVerifier {
7373
// Don't flag references in comments.
7474
return;
7575
}
76+
if (parent is ShowCombinator || parent is HideCombinator) {
77+
return;
78+
}
7679

7780
var annotation = _getUseResultMetadata(element);
7881
if (annotation == null) {

pkg/analyzer/test/generated/patterns_parser_test.dart

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,32 @@ RecordPattern
956956
''');
957957
}
958958

959+
test_constant_identifier_doublyPrefixed_builtin() {
960+
_parse('''
961+
void f(x) {
962+
const y = abstract.as.get; // verify that this works
963+
switch (x) {
964+
case abstract.as.get:
965+
break;
966+
}
967+
}
968+
''');
969+
var node = findNode.switchPatternCase('case abstract.as.get').pattern;
970+
assertParsedNodeText(node, '''
971+
ConstantPattern
972+
expression: PropertyAccess
973+
target: PrefixedIdentifier
974+
prefix: SimpleIdentifier
975+
token: abstract
976+
period: .
977+
identifier: SimpleIdentifier
978+
token: as
979+
operator: .
980+
propertyName: SimpleIdentifier
981+
token: get
982+
''');
983+
}
984+
959985
test_constant_identifier_doublyPrefixed_insideCase() {
960986
_parse('''
961987
void f(x) {
@@ -1089,6 +1115,54 @@ PostfixPattern
10891115
''');
10901116
}
10911117

1118+
test_constant_identifier_doublyPrefixed_pseudoKeyword() {
1119+
_parse('''
1120+
void f(x) {
1121+
const y = show.hide.when; // verify that this works
1122+
switch (x) {
1123+
case show.hide.when:
1124+
break;
1125+
}
1126+
}
1127+
''');
1128+
var node = findNode.switchPatternCase('case show.hide.when').pattern;
1129+
assertParsedNodeText(node, '''
1130+
ConstantPattern
1131+
expression: PropertyAccess
1132+
target: PrefixedIdentifier
1133+
prefix: SimpleIdentifier
1134+
token: show
1135+
period: .
1136+
identifier: SimpleIdentifier
1137+
token: hide
1138+
operator: .
1139+
propertyName: SimpleIdentifier
1140+
token: when
1141+
''');
1142+
}
1143+
1144+
test_constant_identifier_prefixed_builtin() {
1145+
_parse('''
1146+
void f(x) {
1147+
const y = abstract.as; // verify that this works
1148+
switch (x) {
1149+
case abstract.as:
1150+
break;
1151+
}
1152+
}
1153+
''');
1154+
var node = findNode.switchPatternCase('case abstract.as').pattern;
1155+
assertParsedNodeText(node, '''
1156+
ConstantPattern
1157+
expression: PrefixedIdentifier
1158+
prefix: SimpleIdentifier
1159+
token: abstract
1160+
period: .
1161+
identifier: SimpleIdentifier
1162+
token: as
1163+
''');
1164+
}
1165+
10921166
test_constant_identifier_prefixed_insideCase() {
10931167
_parse('''
10941168
void f(x) {
@@ -1202,6 +1276,28 @@ PostfixPattern
12021276
''');
12031277
}
12041278

1279+
test_constant_identifier_prefixed_pseudoKeyword() {
1280+
_parse('''
1281+
void f(x) {
1282+
const y = show.hide; // verify that this works
1283+
switch (x) {
1284+
case show.hide:
1285+
break;
1286+
}
1287+
}
1288+
''');
1289+
var node = findNode.switchPatternCase('case show.hide').pattern;
1290+
assertParsedNodeText(node, '''
1291+
ConstantPattern
1292+
expression: PrefixedIdentifier
1293+
prefix: SimpleIdentifier
1294+
token: show
1295+
period: .
1296+
identifier: SimpleIdentifier
1297+
token: hide
1298+
''');
1299+
}
1300+
12051301
test_constant_identifier_prefixedWithUnderscore_insideCase() {
12061302
// We need to make sure the `_` isn't misinterpreted as a wildcard pattern
12071303
_parse('''
@@ -1224,6 +1320,24 @@ ConstantPattern
12241320
''');
12251321
}
12261322

1323+
test_constant_identifier_unprefixed_builtin() {
1324+
_parse('''
1325+
void f(x) {
1326+
const y = abstract; // verify that this works
1327+
switch (x) {
1328+
case abstract:
1329+
break;
1330+
}
1331+
}
1332+
''');
1333+
var node = findNode.switchPatternCase('case abstract').pattern;
1334+
assertParsedNodeText(node, '''
1335+
ConstantPattern
1336+
expression: SimpleIdentifier
1337+
token: abstract
1338+
''');
1339+
}
1340+
12271341
test_constant_identifier_unprefixed_insideCase() {
12281342
_parse('''
12291343
void f(x) {
@@ -1322,6 +1436,24 @@ PostfixPattern
13221436
''');
13231437
}
13241438

1439+
test_constant_identifier_unprefixed_pseudoKeyword() {
1440+
_parse('''
1441+
void f(x) {
1442+
const y = show; // verify that this works
1443+
switch (x) {
1444+
case show:
1445+
break;
1446+
}
1447+
}
1448+
''');
1449+
var node = findNode.switchPatternCase('case show').pattern;
1450+
assertParsedNodeText(node, '''
1451+
ConstantPattern
1452+
expression: SimpleIdentifier
1453+
token: show
1454+
''');
1455+
}
1456+
13251457
test_constant_list_typed_empty_insideCase() {
13261458
_parse('''
13271459
void f(x) {

pkg/analyzer/test/src/diagnostics/unused_result_test.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,42 @@ void main() {
619619
]);
620620
}
621621

622+
test_import_hide() async {
623+
newFile('$testPackageLibPath/a.dart', r'''
624+
import 'package:meta/meta.dart';
625+
626+
@useResult
627+
bool foo() => true;
628+
629+
bool bar() => true;
630+
''');
631+
632+
await assertNoErrorsInCode(r'''
633+
import 'a.dart' hide foo;
634+
635+
bool f() {
636+
return bar();
637+
}
638+
''');
639+
}
640+
641+
test_import_show() async {
642+
newFile('$testPackageLibPath/a.dart', r'''
643+
import 'package:meta/meta.dart';
644+
645+
@useResult
646+
bool foo() => true;
647+
''');
648+
649+
await assertNoErrorsInCode(r'''
650+
import 'a.dart' show foo;
651+
652+
bool f() {
653+
return foo();
654+
}
655+
''');
656+
}
657+
622658
test_method_result_assertInitializer() async {
623659
await assertNoErrorsInCode('''
624660
import 'package:meta/meta.dart';

pkg/dart2wasm/lib/class_info.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,13 @@ class ClassInfoCollector {
197197
}
198198

199199
// In the Wasm type hierarchy, Object, bool and num sit directly below
200-
// the Top type. The implementation classes (_StringBase, _Type and the
201-
// box classes) sit directly below the public classes they implement.
200+
// the Top type. The implementation classes _StringBase and _Type sit
201+
// directly below the public classes they implement.
202202
// All other classes sit below their superclass.
203203
ClassInfo superInfo = cls == translator.coreTypes.boolClass ||
204204
cls == translator.coreTypes.numClass
205205
? topInfo
206-
: cls == translator.stringBaseClass ||
207-
cls == translator.typeClass ||
208-
translator.boxedClasses.values.contains(cls)
206+
: cls == translator.stringBaseClass || cls == translator.typeClass
209207
? translator.classInfo[cls.implementedTypes.single.classNode]!
210208
: translator.classInfo[superclass]!;
211209

pkg/dart2wasm/lib/intrinsics.dart

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class Intrinsifier {
3838
'<=': (b) => b.i64_le_s(),
3939
'>': (b) => b.i64_gt_s(),
4040
'>=': (b) => b.i64_ge_s(),
41+
'_div_s': (b) => b.i64_div_s(),
42+
'_shl': (b) => b.i64_shl(),
43+
'_shr_s': (b) => b.i64_shr_s(),
44+
'_shr_u': (b) => b.i64_shr_u(),
45+
'_lt_u': (b) => b.i64_lt_u(),
4146
}
4247
},
4348
doubleType: {
@@ -81,13 +86,17 @@ class Intrinsifier {
8186
'truncateToDouble': (b) {
8287
b.f64_trunc();
8388
},
89+
'_toInt': (b) {
90+
b.i64_trunc_sat_f64_s();
91+
},
8492
},
8593
};
8694
static final Map<String, w.ValueType> unaryResultMap = {
8795
'toDouble': w.NumType.f64,
8896
'floorToDouble': w.NumType.f64,
8997
'ceilToDouble': w.NumType.f64,
9098
'truncateToDouble': w.NumType.f64,
99+
'_toInt': w.NumType.i64,
91100
};
92101

93102
Translator get translator => codeGen.translator;
@@ -100,7 +109,7 @@ class Intrinsifier {
100109
}
101110

102111
static bool isComparison(String op) =>
103-
op == '<' || op == '<=' || op == '>' || op == '>=';
112+
op == '<' || op == '<=' || op == '>' || op == '>=' || op == '_lt_u';
104113

105114
Intrinsifier(this.codeGen);
106115

@@ -715,58 +724,6 @@ class Intrinsifier {
715724
codeGen.wrap(typeArguments, translator.types.typeListExpectedType);
716725
b.struct_new(info.struct);
717726
return info.nonNullableType;
718-
case "_div_s":
719-
assert(cls == translator.boxedIntClass);
720-
assert(node.arguments.positional.length == 2);
721-
Expression first = node.arguments.positional[0];
722-
Expression second = node.arguments.positional[1];
723-
codeGen.wrap(first, w.NumType.i64);
724-
codeGen.wrap(second, w.NumType.i64);
725-
b.i64_div_s();
726-
return w.NumType.i64;
727-
case "_shl":
728-
assert(cls == translator.boxedIntClass);
729-
assert(node.arguments.positional.length == 2);
730-
Expression first = node.arguments.positional[0];
731-
Expression second = node.arguments.positional[1];
732-
codeGen.wrap(first, w.NumType.i64);
733-
codeGen.wrap(second, w.NumType.i64);
734-
b.i64_shl();
735-
return w.NumType.i64;
736-
case "_shr_s":
737-
assert(cls == translator.boxedIntClass);
738-
assert(node.arguments.positional.length == 2);
739-
Expression first = node.arguments.positional[0];
740-
Expression second = node.arguments.positional[1];
741-
codeGen.wrap(first, w.NumType.i64);
742-
codeGen.wrap(second, w.NumType.i64);
743-
b.i64_shr_s();
744-
return w.NumType.i64;
745-
case "_shr_u":
746-
assert(cls == translator.boxedIntClass);
747-
assert(node.arguments.positional.length == 2);
748-
Expression first = node.arguments.positional[0];
749-
Expression second = node.arguments.positional[1];
750-
codeGen.wrap(first, w.NumType.i64);
751-
codeGen.wrap(second, w.NumType.i64);
752-
b.i64_shr_u();
753-
return w.NumType.i64;
754-
case "_lt_u":
755-
assert(cls == translator.boxedIntClass);
756-
assert(node.arguments.positional.length == 2);
757-
Expression first = node.arguments.positional[0];
758-
Expression second = node.arguments.positional[1];
759-
codeGen.wrap(first, w.NumType.i64);
760-
codeGen.wrap(second, w.NumType.i64);
761-
b.i64_lt_u();
762-
return w.NumType.i32; // bool
763-
case "_toInt":
764-
assert(cls == translator.boxedDoubleClass);
765-
assert(node.arguments.positional.length == 1);
766-
Expression arg = node.arguments.positional[0];
767-
codeGen.wrap(arg, w.NumType.f64);
768-
b.i64_trunc_sat_f64_s();
769-
return w.NumType.i64;
770727
}
771728
}
772729

0 commit comments

Comments
 (0)