Skip to content

Commit c938793

Browse files
author
Dart CI
committed
Version 2.11.0-169.0.dev
Merge commit 'e3fcb1a646f0111f6b7a9a226ec71b63079b0081' into 'dev'
2 parents 200e8da + e3fcb1a commit c938793

13 files changed

+111
-128
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class PrefixExpressionResolver {
4141

4242
ErrorReporter get _errorReporter => _resolver.errorReporter;
4343

44-
bool get _isNonNullableByDefault => _typeSystem.isNonNullableByDefault;
45-
4644
TypeProvider get _typeProvider => _resolver.typeProvider;
4745

4846
TypeSystemImpl get _typeSystem => _resolver.typeSystem;
@@ -138,17 +136,6 @@ class PrefixExpressionResolver {
138136
}
139137
}
140138

141-
/// Return the non-nullable variant of the [type] if NNBD is enabled, otherwise
142-
/// return the type itself.
143-
///
144-
/// TODO(scheglov) this is duplicate
145-
DartType _nonNullable(DartType type) {
146-
if (_isNonNullableByDefault) {
147-
return _typeSystem.promoteToNonNull(type);
148-
}
149-
return type;
150-
}
151-
152139
/// Record that the static type of the given node is the given type.
153140
///
154141
/// @param expression the node whose type is to be recorded
@@ -227,7 +214,7 @@ class PrefixExpressionResolver {
227214
// No special handling for incremental operators.
228215
} else if (operator.isIncrementOperator) {
229216
if (node.readType.isDartCoreInt) {
230-
staticType = _nonNullable(_typeProvider.intType);
217+
staticType = _typeProvider.intType;
231218
} else {
232219
_checkForInvalidAssignmentIncDec(node, staticType);
233220
}
@@ -252,7 +239,7 @@ class PrefixExpressionResolver {
252239

253240
_resolver.boolExpressionVerifier.checkForNonBoolNegationExpression(operand);
254241

255-
_recordStaticType(node, _nonNullable(_typeProvider.boolType));
242+
_recordStaticType(node, _typeProvider.boolType);
256243

257244
_flowAnalysis?.flow?.logicalNot_end(node, operand);
258245
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ class ResolverVisitor extends ScopedVisitor {
377377
reportConstEvaluationErrors: reportConstEvaluationErrors,
378378
migratableAstInfoProvider: _migratableAstInfoProvider);
379379
inferenceContext = InferenceContext._(this);
380-
typeAnalyzer = StaticTypeAnalyzer(
381-
this, featureSet, _flowAnalysis, migrationResolutionHooks);
380+
typeAnalyzer =
381+
StaticTypeAnalyzer(this, _flowAnalysis, migrationResolutionHooks);
382382
}
383383

384384
/// Return the element representing the function containing the current node,

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

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/dart/analysis/features.dart';
65
import 'package:analyzer/dart/ast/ast.dart';
76
import 'package:analyzer/dart/ast/visitor.dart';
87
import 'package:analyzer/dart/element/element.dart';
@@ -28,9 +27,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
2827
/// The resolver driving the resolution and type analysis.
2928
final ResolverVisitor _resolver;
3029

31-
/// The feature set that should be used to resolve types.
32-
final FeatureSet _featureSet;
33-
3430
final MigrationResolutionHooks _migrationResolutionHooks;
3531

3632
/// The object providing access to the types defined by the language.
@@ -48,17 +44,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
4844
/// [_resolver] based on the
4945
///
5046
/// @param resolver the resolver driving this participant
51-
StaticTypeAnalyzer(this._resolver, this._featureSet, this._flowAnalysis,
52-
this._migrationResolutionHooks) {
47+
StaticTypeAnalyzer(
48+
this._resolver, this._flowAnalysis, this._migrationResolutionHooks) {
5349
_typeProvider = _resolver.typeProvider;
5450
_typeSystem = _resolver.typeSystem;
5551
_dynamicType = _typeProvider.dynamicType;
5652
}
5753

58-
/// Is `true` if the library being analyzed is non-nullable by default.
59-
bool get _isNonNullableByDefault =>
60-
_featureSet.isEnabled(Feature.non_nullable);
61-
6254
/// Given a constructor for a generic type, returns the equivalent generic
6355
/// function type that we could use to forward to the constructor, or for a
6456
/// non-generic type simply returns the constructor type.
@@ -111,7 +103,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
111103
/// `String`.</blockquote>
112104
@override
113105
void visitAdjacentStrings(AdjacentStrings node) {
114-
recordStaticType(node, _nonNullable(_typeProvider.stringType));
106+
recordStaticType(node, _typeProvider.stringType);
115107
}
116108

117109
/// The Dart Language Specification, 12.32: <blockquote>... the cast expression <i>e as T</i> ...
@@ -140,7 +132,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
140132
/// bool.</blockquote>
141133
@override
142134
void visitBooleanLiteral(BooleanLiteral node) {
143-
recordStaticType(node, _nonNullable(_typeProvider.boolType));
135+
recordStaticType(node, _typeProvider.boolType);
144136
}
145137

146138
/// The Dart Language Specification, 12.15.2: <blockquote>A cascaded method invocation expression
@@ -167,7 +159,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
167159
/// double.</blockquote>
168160
@override
169161
void visitDoubleLiteral(DoubleLiteral node) {
170-
recordStaticType(node, _nonNullable(_typeProvider.doubleType));
162+
recordStaticType(node, _typeProvider.doubleType);
171163
}
172164

173165
@override
@@ -242,9 +234,9 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
242234
if (context == null ||
243235
_typeSystem.isAssignableTo2(_typeProvider.intType, context) ||
244236
!_typeSystem.isAssignableTo2(_typeProvider.doubleType, context)) {
245-
recordStaticType(node, _nonNullable(_typeProvider.intType));
237+
recordStaticType(node, _typeProvider.intType);
246238
} else {
247-
recordStaticType(node, _nonNullable(_typeProvider.doubleType));
239+
recordStaticType(node, _typeProvider.doubleType);
248240
}
249241
}
250242

@@ -254,7 +246,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
254246
/// The static type of an is-expression is `bool`.</blockquote>
255247
@override
256248
void visitIsExpression(IsExpression node) {
257-
recordStaticType(node, _nonNullable(_typeProvider.boolType));
249+
recordStaticType(node, _typeProvider.boolType);
258250
}
259251

260252
@override
@@ -292,14 +284,14 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
292284
/// `String`.</blockquote>
293285
@override
294286
void visitSimpleStringLiteral(SimpleStringLiteral node) {
295-
recordStaticType(node, _nonNullable(_typeProvider.stringType));
287+
recordStaticType(node, _typeProvider.stringType);
296288
}
297289

298290
/// The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is
299291
/// `String`.</blockquote>
300292
@override
301293
void visitStringInterpolation(StringInterpolation node) {
302-
recordStaticType(node, _nonNullable(_typeProvider.stringType));
294+
recordStaticType(node, _typeProvider.stringType);
303295
}
304296

305297
@override
@@ -316,7 +308,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
316308

317309
@override
318310
void visitSymbolLiteral(SymbolLiteral node) {
319-
recordStaticType(node, _nonNullable(_typeProvider.symbolType));
311+
recordStaticType(node, _typeProvider.symbolType);
320312
}
321313

322314
/// The Dart Language Specification, 12.10: <blockquote>The static type of `this` is the
@@ -461,13 +453,4 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
461453
constructor.staticElement = constructorElement;
462454
}
463455
}
464-
465-
/// Return the non-nullable variant of the [type] if NNBD is enabled, otherwise
466-
/// return the type itself.
467-
DartType _nonNullable(DartType type) {
468-
if (_isNonNullableByDefault) {
469-
return _typeSystem.promoteToNonNull(type);
470-
}
471-
return type;
472-
}
473456
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class IfElementConditionFromDeferredLibraryTest extends PubPackageResolutionTest
2020
mixin IfElementConditionFromDeferredLibraryTestCases
2121
on PubPackageResolutionTest {
2222
test_inList_deferred() async {
23-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
23+
newFile('$testPackageLibPath/lib1.dart', content: r'''
2424
const bool c = true;''');
2525
await assertErrorsInCode(r'''
2626
import 'lib1.dart' deferred as a;
@@ -33,7 +33,7 @@ f() {
3333
}
3434

3535
test_inList_nonConst() async {
36-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
36+
newFile('$testPackageLibPath/lib1.dart', content: r'''
3737
const bool c = true;''');
3838
await assertNoErrorsInCode(r'''
3939
import 'lib1.dart' deferred as a;
@@ -43,7 +43,7 @@ f() {
4343
}
4444

4545
test_inList_notDeferred() async {
46-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
46+
newFile('$testPackageLibPath/lib1.dart', content: r'''
4747
const bool c = true;''');
4848
await assertNoErrorsInCode(r'''
4949
import 'lib1.dart' as a;
@@ -53,7 +53,7 @@ f() {
5353
}
5454

5555
test_inMap_deferred() async {
56-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
56+
newFile('$testPackageLibPath/lib1.dart', content: r'''
5757
const bool c = true;''');
5858
await assertErrorsInCode(r'''
5959
import 'lib1.dart' deferred as a;
@@ -66,7 +66,7 @@ f() {
6666
}
6767

6868
test_inMap_notConst() async {
69-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
69+
newFile('$testPackageLibPath/lib1.dart', content: r'''
7070
const bool c = true;''');
7171
await assertNoErrorsInCode(r'''
7272
import 'lib1.dart' deferred as a;
@@ -76,7 +76,7 @@ f() {
7676
}
7777

7878
test_inMap_notDeferred() async {
79-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
79+
newFile('$testPackageLibPath/lib1.dart', content: r'''
8080
const bool c = true;''');
8181
await assertNoErrorsInCode(r'''
8282
import 'lib1.dart' as a;
@@ -86,7 +86,7 @@ f() {
8686
}
8787

8888
test_inSet_deferred() async {
89-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
89+
newFile('$testPackageLibPath/lib1.dart', content: r'''
9090
const bool c = true;''');
9191
await assertErrorsInCode(r'''
9292
import 'lib1.dart' deferred as a;
@@ -99,7 +99,7 @@ f() {
9999
}
100100

101101
test_inSet_notConst() async {
102-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
102+
newFile('$testPackageLibPath/lib1.dart', content: r'''
103103
const bool c = true;''');
104104
await assertNoErrorsInCode(r'''
105105
import 'lib1.dart' deferred as a;
@@ -109,7 +109,7 @@ f() {
109109
}
110110

111111
test_inSet_notDeferred() async {
112-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
112+
newFile('$testPackageLibPath/lib1.dart', content: r'''
113113
const bool c = true;''');
114114
await assertNoErrorsInCode(r'''
115115
import 'lib1.dart' as a;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mixin NonConstantListElementFromDeferredLibraryTestCases
2323
@failingTest
2424
test_const_ifElement_thenTrue_deferredElse() async {
2525
// reports wrong error code (which is not crucial to fix)
26-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
26+
newFile('$testPackageLibPath/lib1.dart', content: r'''
2727
const int c = 1;''');
2828
await assertErrorsInCode(r'''
2929
import 'lib1.dart' deferred as a;
@@ -38,7 +38,7 @@ var v = const [ if (cond) 'a' else a.c ];
3838
}
3939

4040
test_const_ifElement_thenTrue_deferredThen() async {
41-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
41+
newFile('$testPackageLibPath/lib1.dart', content: r'''
4242
const int c = 1;''');
4343
await assertErrorsInCode(r'''
4444
import 'lib1.dart' deferred as a;
@@ -53,7 +53,7 @@ var v = const [ if (cond) a.c ];
5353
}
5454

5555
test_const_topLevel_deferred() async {
56-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
56+
newFile('$testPackageLibPath/lib1.dart', content: r'''
5757
const int c = 1;''');
5858
await assertErrorsInCode(r'''
5959
import 'lib1.dart' deferred as a;
@@ -67,7 +67,7 @@ var v = const [a.c];
6767
}
6868

6969
test_const_topLevel_deferred_nested() async {
70-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
70+
newFile('$testPackageLibPath/lib1.dart', content: r'''
7171
const int c = 1;''');
7272
await assertErrorsInCode(r'''
7373
import 'lib1.dart' deferred as a;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mixin NonConstantMapKeyFromDeferredLibraryTestCases
2222
@failingTest
2323
test_const_ifElement_thenTrue_deferredElse() async {
2424
// reports wrong error code
25-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
25+
newFile('$testPackageLibPath/lib1.dart', content: r'''
2626
const int c = 1;''');
2727
await assertErrorsInCode(r'''
2828
import 'lib1.dart' deferred as a;
@@ -35,7 +35,7 @@ var v = const { if (cond) 0: 1 else a.c : 0};
3535
}
3636

3737
test_const_ifElement_thenTrue_deferredThen() async {
38-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
38+
newFile('$testPackageLibPath/lib1.dart', content: r'''
3939
const int c = 1;''');
4040
await assertErrorsInCode(r'''
4141
import 'lib1.dart' deferred as a;
@@ -48,7 +48,7 @@ var v = const { if (cond) a.c : 0};
4848
}
4949

5050
test_const_topLevel_deferred() async {
51-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
51+
newFile('$testPackageLibPath/lib1.dart', content: r'''
5252
const int c = 1;''');
5353
await assertErrorsInCode(r'''
5454
import 'lib1.dart' deferred as a;
@@ -60,7 +60,7 @@ var v = const {a.c : 0};
6060
}
6161

6262
test_const_topLevel_deferred_nested() async {
63-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
63+
newFile('$testPackageLibPath/lib1.dart', content: r'''
6464
const int c = 1;''');
6565
await assertErrorsInCode(r'''
6666
import 'lib1.dart' deferred as a;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mixin NonConstantMapValueFromDeferredLibraryTestCases
2323
@failingTest
2424
test_const_ifElement_thenTrue_elseDeferred() async {
2525
// reports wrong error code
26-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
26+
newFile('$testPackageLibPath/lib1.dart', content: r'''
2727
const int c = 1;''');
2828
await assertErrorsInCode(r'''
2929
import 'lib1.dart' deferred as a;
@@ -36,7 +36,7 @@ var v = const { if (cond) 'a': 'b' else 'c' : a.c};
3636
}
3737

3838
test_const_ifElement_thenTrue_thenDeferred() async {
39-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
39+
newFile('$testPackageLibPath/lib1.dart', content: r'''
4040
const int c = 1;''');
4141
await assertErrorsInCode(r'''
4242
import 'lib1.dart' deferred as a;
@@ -49,7 +49,7 @@ var v = const { if (cond) 'a' : a.c};
4949
}
5050

5151
test_const_topLevel_deferred() async {
52-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
52+
newFile('$testPackageLibPath/lib1.dart', content: r'''
5353
const int c = 1;''');
5454
await assertErrorsInCode(r'''
5555
import 'lib1.dart' deferred as a;
@@ -61,7 +61,7 @@ var v = const {'a' : a.c};
6161
}
6262

6363
test_const_topLevel_deferred_nested() async {
64-
newFile(convertPath('$testPackageLibPath/lib1.dart'), content: r'''
64+
newFile('$testPackageLibPath/lib1.dart', content: r'''
6565
const int c = 1;''');
6666
await assertErrorsInCode(r'''
6767
import 'lib1.dart' deferred as a;

0 commit comments

Comments
 (0)