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

Commit b58cfe5

Browse files
author
Dart CI
committed
Version 2.11.0-230.0.dev
Merge commit 'e5f1b4bb2cf3fe136d8a8fc7313619cf93c07944' into 'dev'
2 parents e655b9a + e5f1b4b commit b58cfe5

File tree

34 files changed

+3228
-2682
lines changed

34 files changed

+3228
-2682
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ class BulkFixProcessor {
297297
CompileTimeErrorCode.UNDEFINED_METHOD: [
298298
DataDriven.newInstance,
299299
],
300+
CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER: [
301+
DataDriven.newInstance,
302+
],
300303
CompileTimeErrorCode.UNDEFINED_SETTER: [
301304
DataDriven.newInstance,
302305
],

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ class DataDriven extends MultiCorrectionProducer {
101101
return const [ElementKind.extensionKind];
102102
} else if (node is InstanceCreationExpression) {
103103
return const [ElementKind.constructorKind];
104+
} else if (node is Label) {
105+
var argumentList = node.parent.parent;
106+
return _kindsForNode(argumentList.parent, child: argumentList);
104107
} else if (node is MethodInvocation) {
108+
assert(child != null);
105109
if (node.target == child) {
106110
return const [
107111
ElementKind.classKind,

pkg/analysis_server/lib/src/services/correction/fix/data_driven/modify_parameters.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ class ModifyParameters extends Change<_Data> {
226226
if (parent is InvocationExpression) {
227227
var argumentList = parent.argumentList;
228228
return _Data(argumentList);
229+
} else if (parent is Label) {
230+
var argumentList = parent.parent.parent;
231+
if (argumentList is ArgumentList) {
232+
return _Data(argumentList);
233+
}
229234
}
230235
return null;
231236
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ class FixProcessor extends BaseProcessor {
591591
],
592592
CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER: [
593593
ChangeArgumentName.newInstance,
594+
DataDriven.newInstance,
594595
],
595596
CompileTimeErrorCode.UNDEFINED_SETTER: [
596597
DataDriven.newInstance,

pkg/analysis_server/test/src/services/correction/fix/data_driven/modify_parameters_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,31 @@ void f(C c) {
642642
''');
643643
}
644644

645+
Future<void>
646+
test_remove_middle_optionalNamed_withArg_notRenamed_deprecated() async {
647+
setPackageContent('''
648+
class C {
649+
void m({int a, @deprecated int b, int c}) {}
650+
}
651+
''');
652+
setPackageData(
653+
_modify(['C', 'm'], [RemoveParameter(NamedParameterReference('b'))]));
654+
await resolveTestUnit('''
655+
import '$importUri';
656+
657+
void f(C c) {
658+
c.m(a: 0, b: 1, c: 2);
659+
}
660+
''');
661+
await assertHasFix('''
662+
import '$importUri';
663+
664+
void f(C c) {
665+
c.m(a: 0, c: 2);
666+
}
667+
''');
668+
}
669+
645670
Future<void> test_remove_multiple_deprecated() async {
646671
setPackageContent('''
647672
class C {

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef WorkToWaitAfterComputingResult = Future<void> Function(String path);
8585
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
8686
class AnalysisDriver implements AnalysisDriverGeneric {
8787
/// The version of data format, should be incremented on every format change.
88-
static const int DATA_VERSION = 112;
88+
static const int DATA_VERSION = 114;
8989

9090
/// The length of the list returned by [_computeDeclaredVariablesSignature].
9191
static const int _declaredVariablesSignatureLength = 4;

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import 'package:analyzer/src/generated/utilities_collection.dart';
4242
import 'package:analyzer/src/generated/utilities_dart.dart';
4343
import 'package:analyzer/src/generated/utilities_general.dart';
4444
import 'package:analyzer/src/summary/idl.dart';
45+
import 'package:analyzer/src/summary2/lazy_ast.dart';
4546
import 'package:analyzer/src/summary2/linked_unit_context.dart';
4647
import 'package:analyzer/src/summary2/reference.dart';
4748
import 'package:analyzer/src/util/comment.dart';
@@ -500,6 +501,7 @@ class ClassElementImpl extends AbstractClassElementImpl
500501

501502
if (linkedNode != null) {
502503
if (linkedNode is ClassOrMixinDeclaration) {
504+
LazyAst.applyResolution(linkedNode);
503505
_createPropertiesAndAccessors();
504506
assert(_accessors != null);
505507
return _accessors;
@@ -544,6 +546,7 @@ class ClassElementImpl extends AbstractClassElementImpl
544546
}
545547

546548
if (linkedNode != null) {
549+
LazyAst.applyResolution(linkedNode);
547550
var context = enclosingUnit.linkedContext;
548551
var containerRef = reference.getChild('@constructor');
549552
_constructors = context.getConstructors(linkedNode).map((node) {
@@ -605,6 +608,7 @@ class ClassElementImpl extends AbstractClassElementImpl
605608

606609
if (linkedNode != null) {
607610
if (linkedNode is ClassOrMixinDeclaration) {
611+
LazyAst.applyResolution(linkedNode);
608612
_createPropertiesAndAccessors();
609613
assert(_fields != null);
610614
return _fields;
@@ -705,6 +709,7 @@ class ClassElementImpl extends AbstractClassElementImpl
705709
}
706710

707711
if (linkedNode != null) {
712+
LazyAst.applyResolution(linkedNode);
708713
var context = enclosingUnit.linkedContext;
709714
var implementsClause = context.getImplementsClause(linkedNode);
710715
if (implementsClause != null) {
@@ -780,6 +785,7 @@ class ClassElementImpl extends AbstractClassElementImpl
780785
}
781786

782787
if (linkedNode != null) {
788+
LazyAst.applyResolution(linkedNode);
783789
var context = enclosingUnit.linkedContext;
784790
var containerRef = reference.getChild('@method');
785791
return _methods = context
@@ -816,6 +822,7 @@ class ClassElementImpl extends AbstractClassElementImpl
816822
}
817823

818824
if (linkedNode != null) {
825+
LazyAst.applyResolution(linkedNode);
819826
var context = enclosingUnit.linkedContext;
820827
var withClause = context.getWithClause(linkedNode);
821828
if (withClause != null) {
@@ -865,7 +872,18 @@ class ClassElementImpl extends AbstractClassElementImpl
865872
}
866873

867874
if (linkedNode != null) {
868-
var type = linkedContext.getSuperclass(linkedNode)?.type;
875+
var node = linkedNode;
876+
LazyAst.applyResolution(node);
877+
878+
DartType type;
879+
if (node is ClassDeclaration) {
880+
type = node.extendsClause?.superclass?.type;
881+
} else if (node is ClassTypeAlias) {
882+
type = linkedContext.getSuperclass(linkedNode)?.type;
883+
} else {
884+
throw UnimplementedError('${node.runtimeType}');
885+
}
886+
869887
if (_isInterfaceTypeClass(type)) {
870888
return _supertype = type;
871889
}
@@ -1964,9 +1982,9 @@ class ConstructorElementImpl extends ExecutableElementImpl
19641982
if (_constantInitializers != null) return _constantInitializers;
19651983

19661984
if (linkedNode != null) {
1967-
return _constantInitializers = linkedContext.getConstructorInitializers(
1968-
linkedNode,
1969-
);
1985+
var node = linkedNode as ConstructorDeclaration;
1986+
LazyAst.applyResolution(node);
1987+
return _constantInitializers = node.initializers;
19701988
}
19711989

19721990
return _constantInitializers;
@@ -2080,13 +2098,13 @@ class ConstructorElementImpl extends ExecutableElementImpl
20802098
if (_redirectedConstructor != null) return _redirectedConstructor;
20812099

20822100
if (linkedNode != null) {
2083-
var context = enclosingUnit.linkedContext;
2101+
var node = linkedNode as ConstructorDeclaration;
2102+
LazyAst.applyResolution(node);
20842103
if (isFactory) {
2085-
var node = context.getConstructorRedirected(linkedNode);
2086-
return _redirectedConstructor = node?.staticElement;
2104+
return _redirectedConstructor =
2105+
node.redirectedConstructor?.staticElement;
20872106
} else {
2088-
var initializers = context.getConstructorInitializers(linkedNode);
2089-
for (var initializer in initializers) {
2107+
for (var initializer in node.initializers) {
20902108
if (initializer is RedirectingConstructorInvocation) {
20912109
return _redirectedConstructor = initializer.staticElement;
20922110
}
@@ -2214,6 +2232,7 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
22142232
if (_constantInitializer != null) return _constantInitializer;
22152233

22162234
if (linkedNode != null) {
2235+
LazyAst.applyResolution(linkedNode);
22172236
var context = enclosingUnit.linkedContext;
22182237
return _constantInitializer = context.readInitializer(linkedNode);
22192238
}
@@ -2984,8 +3003,10 @@ abstract class ElementImpl implements Element {
29843003

29853004
@override
29863005
List<ElementAnnotation> get metadata {
3006+
if (_metadata != null) return _metadata;
3007+
29873008
if (linkedNode != null) {
2988-
if (_metadata != null) return _metadata;
3009+
LazyAst.applyResolution(linkedNode);
29893010
var metadata = linkedContext.getMetadata(linkedNode);
29903011
return _metadata = _buildAnnotations2(enclosingUnit, metadata);
29913012
}
@@ -3491,6 +3512,9 @@ class EnumElementImpl extends AbstractClassElementImpl {
34913512
ConstructorElement getNamedConstructor(String name) => null;
34923513

34933514
void _resynthesizeMembers2() {
3515+
var node = linkedNode as EnumDeclaration;
3516+
LazyAst.applyResolution(node);
3517+
34943518
var fields = <FieldElementImpl>[];
34953519
var getters = <PropertyAccessorElementImpl>[];
34963520

@@ -3518,7 +3542,7 @@ class EnumElementImpl extends AbstractClassElementImpl {
35183542

35193543
// Build fields for all enum constants.
35203544
var containerRef = reference.getChild('@constant');
3521-
var constants = linkedContext.getEnumConstants(linkedNode);
3545+
var constants = node.constants;
35223546
for (var i = 0; i < constants.length; ++i) {
35233547
var constant = constants[i];
35243548
var name = constant.name.name;
@@ -3703,6 +3727,7 @@ abstract class ExecutableElementImpl extends ElementImpl
37033727
if (_parameters != null) return _parameters;
37043728

37053729
if (linkedNode != null) {
3730+
LazyAst.applyResolution(linkedNode);
37063731
var context = enclosingUnit.linkedContext;
37073732
var containerRef = reference.getChild('@parameter');
37083733
var formalParameters = context.getFormalParameters(linkedNode);
@@ -3741,6 +3766,7 @@ abstract class ExecutableElementImpl extends ElementImpl
37413766
if (_returnType != null) return _returnType;
37423767

37433768
if (linkedNode != null) {
3769+
LazyAst.applyResolution(linkedNode);
37443770
var context = enclosingUnit.linkedContext;
37453771
return _returnType = context.getReturnType(linkedNode);
37463772
}
@@ -3929,6 +3955,7 @@ class ExtensionElementImpl extends ElementImpl
39293955

39303956
if (linkedNode != null) {
39313957
if (linkedNode is ExtensionDeclaration) {
3958+
LazyAst.applyResolution(linkedNode);
39323959
_createPropertiesAndAccessors();
39333960
assert(_accessors != null);
39343961
return _accessors;
@@ -3988,7 +4015,9 @@ class ExtensionElementImpl extends ElementImpl
39884015
if (_extendedType != null) return _extendedType;
39894016

39904017
if (linkedNode != null) {
3991-
return _extendedType = linkedContext.getExtendedType(linkedNode).type;
4018+
var node = linkedNode as ExtensionDeclaration;
4019+
LazyAst.applyResolution(linkedNode);
4020+
return _extendedType = node.extendedType.type;
39924021
}
39934022

39944023
return _extendedType;
@@ -4002,6 +4031,7 @@ class ExtensionElementImpl extends ElementImpl
40024031

40034032
if (linkedNode != null) {
40044033
if (linkedNode is ExtensionDeclaration) {
4034+
LazyAst.applyResolution(linkedNode);
40054035
_createPropertiesAndAccessors();
40064036
assert(_fields != null);
40074037
return _fields;
@@ -4041,6 +4071,7 @@ class ExtensionElementImpl extends ElementImpl
40414071
}
40424072

40434073
if (linkedNode != null) {
4074+
LazyAst.applyResolution(linkedNode);
40444075
var context = enclosingUnit.linkedContext;
40454076
var containerRef = reference.getChild('@method');
40464077
return _methods = context
@@ -4507,14 +4538,16 @@ class FunctionTypeAliasElementImpl extends ElementImpl
45074538
if (_function != null) return _function;
45084539

45094540
if (linkedNode != null) {
4541+
LazyAst.applyResolution(linkedNode);
45104542
if (linkedNode is GenericTypeAlias) {
45114543
var context = enclosingUnit.linkedContext;
45124544
var function = context.getGeneticTypeAliasFunction(linkedNode);
45134545
if (function != null) {
4514-
var reference = context.getGenericFunctionTypeReference(function);
4515-
_function = reference.element;
4516-
encloseElement(_function);
4517-
return _function;
4546+
return _function = GenericFunctionTypeElementImpl.forLinkedNode(
4547+
this,
4548+
reference.getChild('@function'),
4549+
function,
4550+
);
45184551
} else {
45194552
return _function = GenericFunctionTypeElementImpl.forOffset(-1)
45204553
..typeParameters = const <TypeParameterElement>[]
@@ -5839,8 +5872,10 @@ class MixinElementImpl extends ClassElementImpl {
58395872
if (_superclassConstraints != null) return _superclassConstraints;
58405873

58415874
if (linkedNode != null) {
5875+
var node = linkedNode as MixinDeclaration;
5876+
LazyAst.applyResolution(node);
58425877
List<InterfaceType> constraints;
5843-
var onClause = enclosingUnit.linkedContext.getOnClause(linkedNode);
5878+
var onClause = node.onClause;
58445879
if (onClause != null) {
58455880
constraints = onClause.superclassConstraints
58465881
.map((node) => node.type)
@@ -6565,8 +6600,9 @@ class ParameterElementImpl extends VariableElementImpl
65656600

65666601
@override
65676602
DartType get typeInternal {
6603+
if (_type != null) return _type;
6604+
65686605
if (linkedNode != null) {
6569-
if (_type != null) return _type;
65706606
var context = enclosingUnit.linkedContext;
65716607
return _type = context.getType(linkedNode);
65726608
}
@@ -7159,6 +7195,7 @@ abstract class PropertyInducingElementImpl
71597195
DartType get typeInternal {
71607196
if (linkedNode != null) {
71617197
if (_type != null) return _type;
7198+
LazyAst.applyResolution(linkedNode);
71627199
_type = linkedContext.getType(linkedNode);
71637200

71647201
// While performing inference during linking, the first step is to collect
@@ -7527,13 +7564,19 @@ mixin TypeParameterizedElementMixin
75277564
if (_typeParameterElements != null) return _typeParameterElements;
75287565

75297566
if (linkedNode != null) {
7567+
LazyAst.applyResolution(linkedNode);
75307568
var typeParameters = linkedContext.getTypeParameters2(linkedNode);
75317569
if (typeParameters == null) {
75327570
return _typeParameterElements = const [];
75337571
}
75347572
var containerRef = reference.getChild('@typeParameter');
75357573
return _typeParameterElements =
75367574
typeParameters.typeParameters.map<TypeParameterElement>((node) {
7575+
var element = node.declaredElement;
7576+
if (element != null) {
7577+
return element;
7578+
}
7579+
75377580
var reference = containerRef.getChild(node.name.name);
75387581
if (reference.hasElementFor(node)) {
75397582
return reference.element as TypeParameterElement;

pkg/analyzer/lib/src/dart/element/member.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ abstract class ExecutableMember extends Member implements ExecutableElement {
242242
for (var entry in member._substitution.map.entries) {
243243
map[entry.key] = substitution.substituteType(entry.value);
244244
}
245-
map.addAll(substitution.map);
246245
combined = Substitution.fromMap(map);
247246
} else {
248247
typeProvider = element.library.typeProvider;

pkg/analyzer/lib/src/dart/element/type_system.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,19 @@ class TypeSystemImpl implements TypeSystem {
12301230
typeParameters,
12311231
considerExtendsClause: false,
12321232
);
1233+
1234+
// It is an error to use a generic function type as a bound.
1235+
// What is worse, inference does not do anything to their type formals.
1236+
// So, we might be left with bounds of their type formals not replaced.
1237+
// Then we cannot store this linked information, because it references
1238+
// types that are not in scope.
1239+
for (var i = 0; i < inferredTypes.length; i++) {
1240+
var inferredType = inferredTypes[i];
1241+
if (inferredType is FunctionType && inferredType.typeFormals.isNotEmpty) {
1242+
inferredTypes[i] = DynamicTypeImpl.instance;
1243+
}
1244+
}
1245+
12331246
var substitution = Substitution.fromPairs(typeParameters, inferredTypes);
12341247

12351248
for (int i = 0; i < srcTypes.length; i++) {

0 commit comments

Comments
 (0)