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

Commit 231a9ea

Browse files
author
Dart CI
committed
Version 2.18.0-91.0.dev
Merge commit '4f0ed6a45cb778c02e1351399d63ddc917f61404' into 'dev'
2 parents 5eb9afa + 4f0ed6a commit 231a9ea

File tree

85 files changed

+1851
-797
lines changed

Some content is hidden

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

85 files changed

+1851
-797
lines changed

.github/move.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/no-response.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ class FeatureComputer {
158158
/// offset is within the given [node], or `null` if the context does not
159159
/// impose any type.
160160
DartType? computeContextType(AstNode node, int offset) {
161-
var type = node
162-
.accept(_ContextTypeVisitor(typeProvider, offset))
163-
?.resolveToBound(typeProvider.objectType);
164-
if (type == null || type.isDynamic) {
161+
final contextType = node.accept(
162+
_ContextTypeVisitor(typeProvider, offset),
163+
);
164+
if (contextType == null || contextType.isDynamic) {
165165
return null;
166166
}
167-
return type;
167+
return typeSystem.resolveToBound(contextType);
168168
}
169169

170170
/// Return the element kind used to compute relevance for the given [element].

pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class TypeMemberContributor extends DartCompletionContributor {
4242
}
4343

4444
// Determine the target expression's type.
45-
var type = expression.staticType?.resolveToBound(request.objectType);
45+
final expressionType = expression.staticType;
46+
var type = expressionType != null
47+
? request.libraryElement.typeSystem.resolveToBound(expressionType)
48+
: null;
4649
if (type == null || type.isDynamic) {
4750
// If the expression does not provide a good type, then attempt to get a
4851
// better type from the element.

pkg/analysis_server/test/src/services/correction/fix/sort_constructor_first_test.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,77 @@ class SortConstructorFirstTest extends FixProcessorLintTest {
8080
@override
8181
String get lintCode => LintNames.sort_constructors_first;
8282

83+
@FailingTest(
84+
reason: 'The beginToken is the comment, which has no previous token.',
85+
issue: 'https://github.com/dart-lang/sdk/issues/48966',
86+
)
87+
Future<void> test_hasComment() async {
88+
await resolveTestCode('''
89+
class A {
90+
void foo() {}
91+
/// comment
92+
A();
93+
}
94+
''');
95+
await assertHasFix('''
96+
class A {
97+
/// comment
98+
A();
99+
void foo() {}
100+
}
101+
''');
102+
}
103+
104+
@FailingTest(
105+
reason: 'The beginToken is the comment, which has no previous token.',
106+
issue: 'https://github.com/dart-lang/sdk/issues/48966',
107+
)
108+
Future<void> test_hasComment_hasMetadata_afterComment() async {
109+
await resolveTestCode('''
110+
const a = 0;
111+
112+
class A {
113+
void foo() {}
114+
/// comment
115+
@a
116+
A();
117+
}
118+
''');
119+
await assertHasFix('''
120+
const a = 0;
121+
122+
class A {
123+
/// comment
124+
@a
125+
A();
126+
void foo() {}
127+
}
128+
''');
129+
}
130+
131+
Future<void> test_hasComment_hasMetadata_beforeComment() async {
132+
await resolveTestCode('''
133+
const a = 0;
134+
135+
class A {
136+
void foo() {}
137+
@a
138+
/// comment
139+
A();
140+
}
141+
''');
142+
await assertHasFix('''
143+
const a = 0;
144+
145+
class A {
146+
@a
147+
/// comment
148+
A();
149+
void foo() {}
150+
}
151+
''');
152+
}
153+
83154
Future<void> test_one_fix() async {
84155
await resolveTestCode('''
85156
class A {

pkg/analyzer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Deprecated `ParameterElement.isNotOptional`, use `isRequired` instead.
33
* Deprecated `ResourceProviderMixin.newFile2`, use `newFile` instead.
44
* Deprecated `ResourceProviderMixin.newAnalysisOptionsYamlFile2`, use `newAnalysisOptionsYamlFile` instead.
5+
* Deprecated `DartType.resolveToBound`, use `TypeSystem.resolveToBound` instead.
56

67
## 4.0.0
78
* Removed deprecated `UriKind` and `Source.uriKind`.

pkg/analyzer/lib/dart/element/type.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ abstract class DartType {
176176
///
177177
/// For any other type, returns `this`. Applies recursively -- if the bound is
178178
/// itself a type parameter, that is resolved too.
179+
@Deprecated('Use TypeSystem.resolveToBound() instead')
179180
DartType resolveToBound(DartType objectType);
180181
}
181182

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ abstract class TypeImpl implements DartType {
10631063
return false;
10641064
}
10651065

1066+
@Deprecated('Use TypeSystem.resolveToBound() instead')
10661067
@override
10671068
DartType resolveToBound(DartType objectType) => this;
10681069

@@ -1201,6 +1202,7 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
12011202
return parameters.contains(element);
12021203
}
12031204

1205+
@Deprecated('Use TypeSystem.resolveToBound() instead')
12041206
@override
12051207
DartType resolveToBound(DartType objectType) {
12061208
final promotedBound = this.promotedBound;

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,26 +1468,26 @@ class TypeSystemImpl implements TypeSystem {
14681468
@override
14691469
DartType resolveToBound(DartType type) {
14701470
if (type is TypeParameterTypeImpl) {
1471-
var element = type.element;
1471+
final promotedBound = type.promotedBound;
1472+
if (promotedBound != null) {
1473+
return resolveToBound(promotedBound);
1474+
}
14721475

1473-
var bound = element.bound;
1476+
final bound = type.element.bound;
14741477
if (bound == null) {
1475-
return typeProvider.objectType;
1478+
return isNonNullableByDefault ? objectQuestion : objectStar;
14761479
}
14771480

1478-
NullabilitySuffix nullabilitySuffix = type.nullabilitySuffix;
1479-
NullabilitySuffix newNullabilitySuffix;
1480-
if (nullabilitySuffix == NullabilitySuffix.question ||
1481-
bound.nullabilitySuffix == NullabilitySuffix.question) {
1482-
newNullabilitySuffix = NullabilitySuffix.question;
1483-
} else if (nullabilitySuffix == NullabilitySuffix.star ||
1484-
bound.nullabilitySuffix == NullabilitySuffix.star) {
1485-
newNullabilitySuffix = NullabilitySuffix.star;
1486-
} else {
1487-
newNullabilitySuffix = NullabilitySuffix.none;
1488-
}
1481+
final resolved = resolveToBound(bound) as TypeImpl;
1482+
1483+
final newNullabilitySuffix = uniteNullabilities(
1484+
uniteNullabilities(
1485+
type.nullabilitySuffix,
1486+
bound.nullabilitySuffix,
1487+
),
1488+
resolved.nullabilitySuffix,
1489+
);
14891490

1490-
var resolved = resolveToBound(bound) as TypeImpl;
14911491
return resolved.withNullability(newNullabilitySuffix);
14921492
}
14931493

pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,6 @@ class BinaryExpressionResolver {
233233
contextType: contextType);
234234
}
235235

236-
/// If the given [type] is a type parameter, resolve it to the type that should
237-
/// be used when looking up members. Otherwise, return the original type.
238-
///
239-
/// TODO(scheglov) this is duplicate
240-
DartType _resolveTypeParameter(DartType type) =>
241-
type.resolveToBound(_typeProvider.objectType);
242-
243236
void _resolveUnsupportedOperator(BinaryExpressionImpl node,
244237
{required DartType? contextType}) {
245238
node.leftOperand.accept(_resolver);
@@ -304,7 +297,7 @@ class BinaryExpressionResolver {
304297
}
305298

306299
var leftType = leftOperand.typeOrThrow;
307-
leftType = _resolveTypeParameter(leftType);
300+
leftType = _typeSystem.resolveToBound(leftType);
308301

309302
if (identical(leftType, NeverTypeImpl.instance)) {
310303
_resolver.errorReporter.reportErrorForNode(
@@ -354,7 +347,7 @@ class BinaryExpressionResolver {
354347
leftType = leftOperand.extendedType!;
355348
} else {
356349
leftType = leftOperand.typeOrThrow;
357-
leftType = _resolveTypeParameter(leftType);
350+
leftType = _typeSystem.resolveToBound(leftType);
358351
}
359352

360353
if (identical(leftType, NeverTypeImpl.instance)) {

pkg/analyzer/lib/src/dart/resolver/comment_reference_resolver.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:analyzer/dart/element/element.dart';
77
import 'package:analyzer/dart/element/type.dart';
88
import 'package:analyzer/src/dart/ast/ast.dart';
99
import 'package:analyzer/src/dart/element/type_provider.dart';
10+
import 'package:analyzer/src/dart/element/type_system.dart';
1011
import 'package:analyzer/src/dart/resolver/type_property_resolver.dart';
1112
import 'package:analyzer/src/generated/resolver.dart';
1213

@@ -21,6 +22,8 @@ class CommentReferenceResolver {
2122
CommentReferenceResolver(this._typeProvider, this._resolver)
2223
: _typePropertyResolver = _resolver.typePropertyResolver;
2324

25+
TypeSystemImpl get _typeSystem => _resolver.typeSystem;
26+
2427
/// Resolves [commentReference].
2528
void resolve(CommentReference commentReference) {
2629
_resolver.errorReporter.lockLevel++;
@@ -150,8 +153,9 @@ class CommentReferenceResolver {
150153
if (enclosingExtension == null) {
151154
return null;
152155
}
153-
var extendedType = enclosingExtension.extendedType
154-
.resolveToBound(_typeProvider.objectType);
156+
var extendedType = _typeSystem.resolveToBound(
157+
enclosingExtension.extendedType,
158+
);
155159
if (extendedType is InterfaceType) {
156160
enclosingType = extendedType;
157161
} else if (extendedType is FunctionType) {

pkg/analyzer/lib/src/dart/resolver/for_resolver.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:analyzer/src/dart/ast/ast.dart';
99
import 'package:analyzer/src/dart/element/element.dart';
1010
import 'package:analyzer/src/dart/element/type.dart';
1111
import 'package:analyzer/src/dart/element/type_schema.dart';
12+
import 'package:analyzer/src/dart/element/type_system.dart';
1213
import 'package:analyzer/src/dart/resolver/assignment_expression_resolver.dart';
1314
import 'package:analyzer/src/dart/resolver/typed_literal_resolver.dart';
1415
import 'package:analyzer/src/error/codes.dart';
@@ -22,6 +23,8 @@ class ForResolver {
2223
required ResolverVisitor resolver,
2324
}) : _resolver = resolver;
2425

26+
TypeSystemImpl get _typeSystem => _resolver.typeSystem;
27+
2528
void resolveElement(ForElementImpl node, CollectionLiteralContext? context) {
2629
var forLoopParts = node.forLoopParts;
2730
void visitBody() {
@@ -57,8 +60,7 @@ class ForResolver {
5760
DartType? _computeForEachElementType(Expression iterable, bool isAsync) {
5861
var iterableType = iterable.staticType;
5962
if (iterableType == null) return null;
60-
iterableType =
61-
iterableType.resolveToBound(_resolver.typeProvider.objectType);
63+
iterableType = _typeSystem.resolveToBound(iterableType);
6264

6365
ClassElement iteratedElement = isAsync
6466
? _resolver.typeProvider.streamElement

pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -868,15 +868,6 @@ class MethodInvocationResolver {
868868
}
869869
}
870870

871-
/// If the given [type] is a type parameter, replace with its bound.
872-
/// Otherwise, return the original type.
873-
DartType _resolveTypeParameter(DartType type) {
874-
if (type is TypeParameterType) {
875-
return type.resolveToBound(_resolver.typeProvider.objectType);
876-
}
877-
return type;
878-
}
879-
880871
/// We have identified that [node] is not a real [MethodInvocation],
881872
/// because it does not invoke a method, but instead invokes the result
882873
/// of a getter execution, or implicitly invokes the `call` method of
@@ -885,7 +876,7 @@ class MethodInvocationResolver {
885876
void _rewriteAsFunctionExpressionInvocation(
886877
MethodInvocationImpl node, DartType getterReturnType,
887878
{required DartType? contextType}) {
888-
var targetType = _resolveTypeParameter(getterReturnType);
879+
var targetType = _typeSystem.resolveToBound(getterReturnType);
889880
_inferenceHelper.recordStaticType(node.methodName, targetType,
890881
contextType: contextType);
891882

pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class PropertyElementResolver {
6868
}
6969

7070
var targetType = target.typeOrThrow;
71-
targetType = _resolveTypeParameter(targetType);
71+
targetType = _typeSystem.resolveToBound(targetType);
7272

7373
if (targetType.isVoid) {
7474
// TODO(scheglov) Report directly in TypePropertyResolver?
@@ -815,15 +815,6 @@ class PropertyElementResolver {
815815
);
816816
}
817817

818-
/// If the given [type] is a type parameter, replace with its bound.
819-
/// Otherwise, return the original type.
820-
DartType _resolveTypeParameter(DartType type) {
821-
if (type is TypeParameterType) {
822-
return type.resolveToBound(_resolver.typeProvider.objectType);
823-
}
824-
return type;
825-
}
826-
827818
PropertyElementResolverResult _toIndexResult(ResolutionResult result) {
828819
var readElement = result.getter;
829820
var writeElement = result.setter;

pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class TypePropertyResolver {
282282
bool ifNullSafe = false,
283283
}) {
284284
if (_typeSystem.isNonNullableByDefault ? ifNullSafe : ifLegacy) {
285-
return type.resolveToBound(_typeProvider.objectType);
285+
return _typeSystem.resolveToBound(type);
286286
} else {
287287
return type;
288288
}

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
23932393
// The object being iterated has to implement Iterable<T> for some T that
23942394
// is assignable to the variable's type.
23952395
// TODO(rnystrom): Move this into mostSpecificTypeArgument()?
2396-
iterableType = iterableType.resolveToBound(_typeProvider.objectType);
2396+
iterableType = typeSystem.resolveToBound(iterableType);
23972397

23982398
var requiredSequenceType = awaitKeyword != null
23992399
? _typeProvider.streamDynamicType

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class _ClassIntrospector implements macro.ClassIntrospector {
486486
return null;
487487
}
488488

489-
return declarationBuilder.fromElement.classDeclaration(
489+
return declarationBuilder.fromElement.classElement(
490490
superType.element,
491491
);
492492
}

0 commit comments

Comments
 (0)