Skip to content

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)) {

0 commit comments

Comments
 (0)