Skip to content

Commit 2c434ee

Browse files
author
Dart CI
committed
Version 3.13.0-151.0.dev
Merge 3b81982 into dev
2 parents 2f0bb4c + 3b81982 commit 2c434ee

107 files changed

Lines changed: 2173 additions & 878 deletions

File tree

Some content is hidden

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

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ vars = {
5959

6060
# co19 is a cipd package automatically generated for each co19 commit.
6161
# Use tests/co19/update.sh to update this hash.
62-
"co19_rev": "8a302a4666a9adae63b52fb49f37e7407935f13c",
62+
"co19_rev": "4d2914a4cbb97eeb67ebcc6618bead6a584beb1e",
6363

6464
# The internal benchmarks to use. See go/dart-benchmarks-internal
6565
"benchmarks_internal_rev": "6058722b4643b62c757dadc006f00bc3e14c4380",

pkg/analysis_server/lib/src/services/correction/dart/convert_to_initializing_formal.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,24 @@ class ConvertToInitializingFormal extends ResolvedCorrectionProducer {
346346
if (parameterName == null) return;
347347
var container = node.thisOrAncestorOfType<CompilationUnitMember>();
348348
if (container == null) return;
349-
if (parameter.functionTypedSuffix != null) return;
349+
350350
await builder.addDartFileEdit(file, (builder) {
351-
var type = parameter.type;
352351
// Remove the `var` or `final` keyword, and add `this.`.
353352
builder.addSimpleReplacement(
354353
range.startStart(keyword, parameterName),
355354
'this.',
356355
);
356+
// Remove the function parameters, if there are any.
357+
var suffix = parameter.functionTypedSuffix;
358+
if (suffix != null) {
359+
builder.addDeletion(range.node(suffix));
360+
}
357361
// Add the field.
358362
builder.insertField(container, (builder) {
359363
builder.writeFieldDeclaration(
360364
parameterName.lexeme,
361365
isFinal: keyword.keyword == Keyword.FINAL,
362-
type: type?.type,
366+
type: parameter.declaredFragment?.element.type,
363367
);
364368
});
365369
});

pkg/analysis_server/test/src/services/correction/assist/convert_to_initializing_formal_test.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ class C(this.test) {
295295
await resolveTestCode('''
296296
class C(var int ^test(String));
297297
''');
298-
await assertNoAssist();
298+
await assertHasAssist('''
299+
class C(this.test) {
300+
int Function(String) test;
301+
}
302+
''');
299303
}
300304

301305
Future<void> test_parameterDeclaration_primary_declaring_var() async {

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,6 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
115115
);
116116
}
117117
}
118-
119-
for (var parameter in node.parameters.parameters) {
120-
if (parameter is SuperFormalParameter) {
121-
var element = parameter.declaredFragment?.element;
122-
if (element is SuperFormalParameterElement) {
123-
var superConstructorParameter = element.superConstructorParameter;
124-
if (superConstructorParameter != null) {
125-
usedElements.addElement(superConstructorParameter);
126-
}
127-
}
128-
}
129-
}
130-
131118
super.visitConstructorDeclaration(node);
132119
}
133120

@@ -368,6 +355,18 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
368355
super.visitSuperConstructorInvocation(node);
369356
}
370357

358+
@override
359+
void visitSuperFormalParameter(SuperFormalParameter node) {
360+
var element = node.declaredFragment?.element;
361+
if (element is SuperFormalParameterElement) {
362+
var superConstructorParameter = element.superConstructorParameter;
363+
if (superConstructorParameter != null) {
364+
usedElements.addElement(superConstructorParameter);
365+
}
366+
}
367+
super.visitSuperFormalParameter(node);
368+
}
369+
371370
@override
372371
void visitVariableDeclarationList(VariableDeclarationList node) {
373372
node.metadata.accept(this);

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3266,6 +3266,30 @@ f() => A()._m(0);
32663266
''');
32673267
}
32683268

3269+
test_parameter_isUsed_superParameter_inPrimaryConstructor_optionalNamed() async {
3270+
await resolveTestCodeWithDiagnostics(r'''
3271+
class _BaseNamedOptional({final int? value});
3272+
3273+
class SubNamedOptional({super.value}) extends _BaseNamedOptional;
3274+
3275+
void main() {
3276+
print(SubNamedOptional(value: 42));
3277+
}
3278+
''');
3279+
}
3280+
3281+
test_parameter_isUsed_superParameter_inPrimaryConstructor_optionalPositional() async {
3282+
await resolveTestCodeWithDiagnostics(r'''
3283+
class _BaseOptional([final int? value]);
3284+
3285+
class SubOptional(super.value) extends _BaseOptional;
3286+
3287+
void main() {
3288+
print(SubOptional(42));
3289+
}
3290+
''');
3291+
}
3292+
32693293
test_parameter_isUsed_topLevel() async {
32703294
await resolveTestCodeWithDiagnostics(r'''
32713295
void _m([int? a]) {}

pkg/front_end/lib/src/base/incremental_compiler.dart

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,8 @@ import '../kernel/benchmarker.dart' show BenchmarkPhases, Benchmarker;
9393
import '../kernel/dart_scope_calculator.dart' show DartScope, DartScopeBuilder2;
9494
import '../kernel/hierarchy/hierarchy_builder.dart' show ClassHierarchyBuilder;
9595
import '../kernel/internal_ast.dart'
96-
show
97-
VariableDeclarationImpl,
98-
InternalVariableGet,
99-
InternalVariableSet,
100-
InternalVariable;
96+
show InternalVariableGet, InternalVariableSet, InternalVariable;
97+
import '../kernel/internal_ast_helper.dart' as intern;
10198
import '../kernel/kernel_target.dart' show BuildResult, KernelTarget;
10299
import '../source/check_helper.dart';
103100
import '../source/source_compilation_unit.dart' show SourceCompilationUnitImpl;
@@ -1877,7 +1874,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
18771874
return null;
18781875
}
18791876
LibraryBuilder libraryBuilder = compilationUnit.libraryBuilder;
1880-
List<VariableDeclarationImpl> extraKnownVariables = [];
1877+
List<InternalVariable> extraKnownVariables = [];
18811878
String? usedMethodName = methodName;
18821879
Substitution? substitution;
18831880
if (scriptUri != null && offset != TreeNode.noOffset) {
@@ -1942,8 +1939,11 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
19421939
def.value.isConst &&
19431940
def.value.initializer is ConstantExpression) {
19441941
extraKnownVariables.add(
1945-
new VariableDeclarationImpl(
1946-
def.key,
1942+
intern.createLocalVariable(
1943+
isClosureContextLoweringEnabled: lastGoodKernelTarget
1944+
.loader
1945+
.isClosureContextLoweringEnabled,
1946+
name: def.key,
19471947
type: substitution.substituteType(def.value.type),
19481948
isConst: true,
19491949
hasDeclaredInitializer: true,
@@ -1962,8 +1962,11 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
19621962
// captured? Either way there's something shadowing any fields
19631963
// etc.
19641964
extraKnownVariables.add(
1965-
new VariableDeclarationImpl(
1966-
def.key,
1965+
intern.createLocalVariable(
1966+
isClosureContextLoweringEnabled: lastGoodKernelTarget
1967+
.loader
1968+
.isClosureContextLoweringEnabled,
1969+
name: def.key,
19671970
type: substitution.substituteType(def.value.type),
19681971
isConst: false,
19691972
fileOffset: def.value.fileOffset,
@@ -2225,7 +2228,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
22252228
MemoryFileSystem fs = hfs.memory;
22262229
fs.entityForUri(debugExprUri).writeAsStringSync(expression);
22272230

2228-
Variable? extensionThis;
2231+
InternalVariable? extensionThis;
22292232

22302233
// TODO: pass variable declarations instead of
22312234
// parameter names for proper location detection.
@@ -2236,8 +2239,10 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
22362239
positionalParameters: usedDefinitions.entries.map<Variable>((
22372240
MapEntry<String, DartType> def,
22382241
) {
2239-
VariableDeclarationImpl variable = new VariableDeclarationImpl(
2240-
def.key,
2242+
InternalVariable variable = intern.createPositionalParameter(
2243+
isClosureContextLoweringEnabled:
2244+
lastGoodKernelTarget.loader.isClosureContextLoweringEnabled,
2245+
cosmeticName: def.key,
22412246
type: def.value,
22422247
fileOffset: offsetToUse ?? libraryBuilder.library.fileOffset,
22432248
);
@@ -2248,7 +2253,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
22482253
// The `#this` variable is special.
22492254
extensionThis = variable..isLowered = true;
22502255
}
2251-
return variable;
2256+
return variable.astVariable;
22522257
}).toList(),
22532258
);
22542259

@@ -2390,13 +2395,18 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
23902395
String path = importUri.path;
23912396
int firstSlash = path.indexOf('/');
23922397
String packageName = path.substring(0, firstSlash);
2398+
Package? previousPackage = _previousPackagesMap?[packageName];
2399+
Package? currentPackage = _currentPackagesMap![packageName];
23932400
if (_previousPackagesMap == null ||
2394-
!_packagesEqual(
2395-
_previousPackagesMap![packageName],
2396-
_currentPackagesMap![packageName],
2397-
)) {
2401+
!_packagesEqual(previousPackage, currentPackage)) {
2402+
// TODO(jensj): If the package has changed do we need to check the
2403+
// uri/language version before bailing? If for instance we don't care
2404+
// about the "extraData" field, we should probably just not check that
2405+
// in "_packagesEqual".
23982406
Uri? newFileUri = uriTranslator.translate(importUri, false);
2399-
if (newFileUri != fileUri) {
2407+
if (newFileUri != fileUri ||
2408+
previousPackage?.languageVersion !=
2409+
currentPackage?.languageVersion) {
24002410
invalidatedBecauseOfPackageUpdate = true;
24012411
return true;
24022412
}
@@ -2555,10 +2565,10 @@ class ExpressionEvaluationHelperImpl implements ExpressionEvaluationHelper {
25552565
final ClassHierarchy hierarchy;
25562566

25572567
ExpressionEvaluationHelperImpl(
2558-
List<VariableDeclarationImpl> extraKnown,
2568+
List<InternalVariable> extraKnown,
25592569
this.hierarchy,
25602570
) {
2561-
for (VariableDeclarationImpl variable in extraKnown) {
2571+
for (InternalVariable variable in extraKnown) {
25622572
if (variable.isConst) {
25632573
// We allow const variables - these are inlined (we check
25642574
// `alwaysInlineConstants` in `compileExpression`).

pkg/front_end/lib/src/base/modifiers.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ extension type const Modifiers(int _mask) implements Object {
332332
/// ```
333333
static const Modifiers Required = const Modifiers(_requiredMask);
334334

335+
// Coverage-ignore(suite): Not run.
335336
/// Returns `true` if the set of modifiers contains `required'.
336337
bool get isRequired => (_mask & _requiredMask) != 0;
337338

0 commit comments

Comments
 (0)