Skip to content

Commit 996fe4d

Browse files
author
Dart CI
committed
Version 2.19.0-394.0.dev
Merge 29c3fea into dev
2 parents 7bdd565 + 29c3fea commit 996fe4d

35 files changed

Lines changed: 820 additions & 177 deletions

File tree

.github/workflows/no-response.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# A workflow to close issues where the author hasn't responded to a request for
2+
# more information; see https://github.com/godofredoc/no-response for docs.
3+
4+
name: No Response
5+
6+
# Both `issue_comment` and `scheduled` event types are required.
7+
on:
8+
issue_comment:
9+
types: [created]
10+
schedule:
11+
# Schedule for five minutes after the hour, every hour
12+
- cron: '5 * * * *'
13+
14+
# All permissions not specified are set to 'none'.
15+
permissions:
16+
issues: write
17+
18+
jobs:
19+
noResponse:
20+
runs-on: ubuntu-latest
21+
if: ${{ github.repository == 'dart-lang/sdk' }}
22+
steps:
23+
- uses: godofredoc/no-response@0ce2dc0e63e1c7d2b87752ceed091f6d32c9df09
24+
with:
25+
responseRequiredLabel: "needs-info"
26+
responseRequiredColor: 4774bc
27+
closeComment: >
28+
Without additional information we're not able to resolve this
29+
issue, so it will be closed at this time. You're still free to add
30+
more info and respond to any questions above, though. We'll re-open
31+
the case if you do. Thanks for your contribution!
32+
daysUntilClose: 14
33+
token: ${{ github.token }}

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ vars = {
150150
"pool_rev": "1ea5b031cfda37786d305292cb8104dffb45d9ae",
151151
"protobuf_rev": "4af1cb3c4e116d02d3b3d005fd9d4995fbc4c564",
152152
"pub_rev": "6ac42d7644dedfcc500147ab47886eecab4b1b38", # manually rev'd
153-
"pub_semver_rev": "5ac4c28f6d5f2ac737ed5443a3ffcb1d18e2b271",
153+
"pub_semver_rev": "28159b8c5b96fc2709d0904389d7932880f68659", # b/258766867
154154
"root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50",
155155
"shelf_rev": "5fd2593d47120232054ebcc794f3a028d903f1f8",
156156
"source_map_stack_trace_rev": "8d8078fcc81c8f7936805cd277198493e0b7fc62",

OWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Global approvers - only to be used as a last resort.
22
asiva@google.com #{LAST_RESORT_SUGGESTION}
33
athom@google.com #{LAST_RESORT_SUGGESTION}
4+
devoncarew@google.com #{LAST_RESORT_SUGGESTION}
45
kustermann@google.com #{LAST_RESORT_SUGGESTION}
56
leafp@google.com #{LAST_RESORT_SUGGESTION}
67
sigmund@google.com #{LAST_RESORT_SUGGESTION}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
//
5+
// Measure performance of string comparison.
6+
7+
import 'package:benchmark_harness/benchmark_harness.dart';
8+
9+
class LongStringCompare extends BenchmarkBase {
10+
late String s, t;
11+
12+
String generateLongString() {
13+
var s = "abcdefgh";
14+
for (int i = 0; i < 20; i++) {
15+
s = "$s ghijkl $s";
16+
}
17+
return s;
18+
}
19+
20+
LongStringCompare() : super('LongStringCompare') {
21+
s = generateLongString();
22+
t = s;
23+
// Difference in two strings goes in the middle.
24+
s += "." + s;
25+
t += "!" + t;
26+
}
27+
28+
@override
29+
void warmup() {
30+
for (int i = 0; i < 4; i++) {
31+
run();
32+
}
33+
}
34+
35+
@override
36+
void run() {
37+
bool b = true;
38+
for (int i = 0; i < 5; i++) {
39+
b &= (s == t);
40+
}
41+
}
42+
}
43+
44+
void main() {
45+
LongStringCompare().report();
46+
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,12 @@ mixin TypeAnalyzer<
10641064
///
10651065
/// Stack effect: none.
10661066
Type analyzeVariablePattern(
1067-
Type matchedType,
1068-
MatchContext<Node, Expression, Pattern, Type, Variable> context,
1069-
Pattern node,
1070-
Variable? variable,
1071-
Type? declaredType,
1072-
{required bool isFinal}) {
1067+
Type matchedType,
1068+
MatchContext<Node, Expression, Pattern, Type, Variable> context,
1069+
Pattern node,
1070+
Variable? variable,
1071+
Type? declaredType,
1072+
) {
10731073
Type staticType =
10741074
declaredType ?? variableTypeFromInitializerType(matchedType);
10751075
Node? irrefutableContext = context.irrefutableContext;
@@ -1095,7 +1095,7 @@ mixin TypeAnalyzer<
10951095
// TODO(paulberry): do we need to verify that all instances of a
10961096
// variable are final or all are not final?
10971097
flow?.initialize(variable, matchedType, context.getInitializer(node),
1098-
isFinal: context.isFinal || isFinal,
1098+
isFinal: context.isFinal || isVariableFinal(variable),
10991099
isLate: context.isLate,
11001100
isImplicitlyTyped: isImplicitlyTyped);
11011101
}
@@ -1302,6 +1302,9 @@ mixin TypeAnalyzer<
13021302
/// `default` clause.
13031303
bool isSwitchExhaustive(Node node, Type expressionType);
13041304

1305+
/// Returns whether [node] is final.
1306+
bool isVariableFinal(Variable node);
1307+
13051308
/// Queries whether [pattern] is a variable pattern.
13061309
bool isVariablePattern(Node pattern);
13071310

pkg/_fe_analyzer_shared/test/mini_ast.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,9 @@ Statement while_(Expression condition, List<Statement> body) {
294294
location: location);
295295
}
296296

297-
Pattern wildcard(
298-
{String? type, String? expectInferredType, bool isFinal = false}) =>
297+
Pattern wildcard({String? type, String? expectInferredType}) =>
299298
_VariablePattern(type == null ? null : Type(type), null, expectInferredType,
300-
isFinal: isFinal, location: computeLocation());
299+
location: computeLocation());
301300

302301
typedef SharedMatchContext
303302
= shared.MatchContext<Node, Expression, Pattern, Type, Var>;
@@ -1252,11 +1251,12 @@ abstract class TryStatement extends Statement implements TryBuilder {
12521251
/// analysis testing.
12531252
class Var extends Node implements Promotable {
12541253
final String name;
1254+
final bool isFinal;
12551255

12561256
/// The type of the variable, or `null` if it is not yet known.
12571257
Type? _type;
12581258

1259-
Var(this.name) : super._(location: computeLocation());
1259+
Var(this.name, {this.isFinal = false}) : super._(location: computeLocation());
12601260

12611261
/// Creates an L-value representing a reference to this variable.
12621262
LValue get expr =>
@@ -1278,11 +1278,10 @@ class Var extends Node implements Promotable {
12781278
_type = value;
12791279
}
12801280

1281-
Pattern pattern(
1282-
{String? type, String? expectInferredType, bool isFinal = false}) =>
1281+
Pattern pattern({String? type, String? expectInferredType}) =>
12831282
new _VariablePattern(
12841283
type == null ? null : Type(type), this, expectInferredType,
1285-
isFinal: isFinal, location: computeLocation());
1284+
location: computeLocation());
12861285

12871286
@override
12881287
void preVisit(PreVisitor visitor) {}
@@ -3220,6 +3219,11 @@ class _MiniAstTypeAnalyzer
32203219
return node.isExhaustive;
32213220
}
32223221

3222+
@override
3223+
bool isVariableFinal(Var node) {
3224+
return node.isFinal;
3225+
}
3226+
32233227
@override
32243228
bool isVariablePattern(Node pattern) => pattern is _VariablePattern;
32253229

@@ -3925,10 +3929,8 @@ class _VariablePattern extends Pattern {
39253929

39263930
final String? expectInferredType;
39273931

3928-
final bool isFinal;
3929-
39303932
_VariablePattern(this.declaredType, this.variable, this.expectInferredType,
3931-
{this.isFinal = false, required super.location})
3933+
{required super.location})
39323934
: super._();
39333935

39343936
Type computeSchema(Harness h) =>
@@ -3949,8 +3951,7 @@ class _VariablePattern extends Pattern {
39493951
SharedMatchContext context,
39503952
) {
39513953
var staticType = h.typeAnalyzer.analyzeVariablePattern(
3952-
matchedType, context, this, variable, declaredType,
3953-
isFinal: isFinal);
3954+
matchedType, context, this, variable, declaredType);
39543955
h.typeAnalyzer.handleVariablePattern(this,
39553956
matchedType: matchedType, staticType: staticType);
39563957
}

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE:
12791279
status: hasFix
12801280
HintCode.CAST_FROM_NULL_ALWAYS_FAILS:
12811281
status: needsEvaluation
1282+
HintCode.CAST_FROM_NULLABLE_ALWAYS_FAILS:
1283+
status: needsEvaluation
12821284
HintCode.DEAD_CODE:
12831285
status: hasFix
12841286
HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH:

pkg/analysis_server/test/services/correction/name_suggestion_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ void main() {
1818
class VariableNameSuggestionTest extends AbstractSingleUnitTest {
1919
Future<void> test_forExpression_cast() async {
2020
await resolveTestCode('''
21-
void f() {
22-
var sortedNodes;
21+
void f(Object sortedNodes) {
2322
var res = sortedNodes as String;
2423
}
2524
''');

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13563,8 +13563,7 @@ class VariablePatternImpl extends DartPatternImpl implements VariablePattern {
1356313563
SharedMatchContext context,
1356413564
) {
1356513565
resolverVisitor.analyzeVariablePattern(
13566-
matchedType, context, this, declaredElement, type?.typeOrThrow,
13567-
isFinal: keyword?.keyword == Keyword.FINAL);
13566+
matchedType, context, this, declaredElement, type?.typeOrThrow);
1356813567
}
1356913568

1357013569
@override

pkg/analyzer/lib/src/dart/error/hint_codes.g.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ class HintCode extends AnalyzerErrorCode {
6666
correctionMessage: "Replace the '.' with a '?.' in the invocation.",
6767
);
6868

69+
/// Parameters:
70+
/// 0: the name of the unassigned variable
71+
static const HintCode CAST_FROM_NULLABLE_ALWAYS_FAILS = HintCode(
72+
'CAST_FROM_NULLABLE_ALWAYS_FAILS',
73+
"This cast will always throw an exception because the nullable local "
74+
"variable '{0}' is not assigned.",
75+
correctionMessage:
76+
"Try giving it an initializer expression, or ensure that it's assigned "
77+
"on every execution path.",
78+
);
79+
6980
/// No parameters.
7081
static const HintCode CAST_FROM_NULL_ALWAYS_FAILS = HintCode(
7182
'CAST_FROM_NULL_ALWAYS_FAILS',

0 commit comments

Comments
 (0)