Skip to content

Commit 8c664d4

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Revert "Issue 42797. Understand in legacy libraries that a function returning Never (in Null Safety library) never returns."
This reverts commit 6bba750. Reason for revert: Starts reporting new hints in front-end libraries. Breaks bots. Will clean-up and reland. Original change's description: > Issue 42797. Understand in legacy libraries that a function returning Never (in Null Safety library) never returns. > > R=​[email protected] > > Bug: #42797 > Change-Id: I14e50c231935a4025d33762843f5a54a1ee2154c > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155500 > Reviewed-by: Brian Wilkerson <[email protected]> [email protected],[email protected] Change-Id: I99e845d9bd1d9c0882fecc8d72d18d5582454461 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: #42797 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155540 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 2efb5be commit 8c664d4

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typedef WorkToWaitAfterComputingResult = Future<void> Function(String path);
9191
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
9292
class AnalysisDriver implements AnalysisDriverGeneric {
9393
/// The version of data format, should be incremented on every format change.
94-
static const int DATA_VERSION = 107;
94+
static const int DATA_VERSION = 106;
9595

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

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/token.dart';
77
import 'package:analyzer/dart/ast/visitor.dart';
88
import 'package:analyzer/dart/element/element.dart';
9-
import 'package:analyzer/src/dart/element/type.dart';
109

1110
/// Instances of the class `ExitDetector` determine whether the visited AST node
1211
/// is guaranteed to terminate by executing a `return` statement, `throw`
@@ -424,7 +423,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
424423
}
425424
}
426425
Element element = node.methodName.staticElement;
427-
if (_elementExits(element)) {
426+
if (element != null && element.hasAlwaysThrows) {
428427
return true;
429428
}
430429
return _nodeExits(node.argumentList);
@@ -661,14 +660,4 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
661660
static bool exits(AstNode node) {
662661
return ExitDetector()._nodeExits(node);
663662
}
664-
665-
static bool _elementExits(Element element) {
666-
if (element is ExecutableElement) {
667-
var declaration = element.declaration;
668-
return declaration.hasAlwaysThrows ||
669-
identical(declaration.returnType, NeverTypeImpl.instance);
670-
}
671-
672-
return false;
673-
}
674663
}

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import 'package:analyzer/src/test_utilities/package_mixin.dart';
77
import 'package:test_reflective_loader/test_reflective_loader.dart';
88

99
import '../dart/resolution/driver_resolution.dart';
10-
import '../dart/resolution/with_null_safety_mixin.dart';
1110

1211
main() {
1312
defineReflectiveSuite(() {
1413
defineReflectiveTests(MissingReturnTest);
15-
defineReflectiveTests(MissingReturnWithNullSafetyTest);
1614
});
1715
}
1816

@@ -215,23 +213,3 @@ class B extends A {
215213
]);
216214
}
217215
}
218-
219-
@reflectiveTest
220-
class MissingReturnWithNullSafetyTest extends DriverResolutionTest
221-
with WithNullSafetyMixin {
222-
test_returnNever() async {
223-
newFile('/test/lib/a.dart', content: r'''
224-
Never foo() {
225-
throw 0;
226-
}
227-
''');
228-
await assertNoErrorsInCode(r'''
229-
// @dart = 2.8
230-
import 'a.dart';
231-
232-
int f() {
233-
foo();
234-
}
235-
''');
236-
}
237-
}

0 commit comments

Comments
 (0)