Skip to content

Commit

Permalink
Version 3.1.0-213.0.dev
Browse files Browse the repository at this point in the history
Merge 9ecdfb6 into dev
  • Loading branch information
Dart CI committed Jun 14, 2023
2 parents 922c315 + 9ecdfb6 commit 8eaed33
Show file tree
Hide file tree
Showing 19 changed files with 297 additions and 173 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ vars = {
# The list of revisions for these tools comes from Fuchsia, here:
# https://fuchsia.googlesource.com/integration/+/HEAD/toolchain
# If there are problems with the toolchain, contact fuchsia-toolchain@.
"clang_version": "git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d",
"clang_version": "git_revision:7f374b6902fad9caed41284a57d573abe9ada9d1",
"gn_version": "git_revision:e3978de3e8dafb50a2b11efa784e08699a43faf8",

# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/gn
Expand Down
23 changes: 19 additions & 4 deletions pkg/analyzer/lib/src/error/best_practices_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1535,14 +1535,29 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
/// In "strict-inference" mode, check that [returnType] is specified.
void _checkStrictInferenceReturnType(
AstNode? returnType, AstNode reportNode, String displayName) {
if (!_strictInference) {
if (!_strictInference || returnType != null) {
return;
}
if (returnType == null) {
_errorReporter.reportErrorForNode(

switch (reportNode) {
case MethodDeclaration():
_errorReporter.reportErrorForToken(
WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
reportNode.name,
[displayName],
);
case FunctionDeclaration():
_errorReporter.reportErrorForToken(
WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
reportNode.name,
[displayName],
);
case _:
_errorReporter.reportErrorForNode(
WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
reportNode,
[displayName]);
[displayName],
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class InferenceFailureOnFunctionReturnTypeTest
class C {
get f => 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 11)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 16, 1)]);
}

test_classInstanceMethod() async {
await assertErrorsInCode(r'''
class C {
f() => 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 9)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 1)]);
}

test_classInstanceMethod_overriding() async {
Expand Down Expand Up @@ -90,7 +90,7 @@ class C {
class C {
operator +(int x) => print(x);
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 30)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 21, 1)]);
}

test_classInstanceSetter() async {
Expand All @@ -106,7 +106,7 @@ class C {
class C {
static f() => 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 16)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 19, 1)]);
}

test_classStaticMethod_withType() async {
Expand All @@ -124,7 +124,7 @@ extension E on List {
return 7;
}
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 24, 23)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 24, 1)]);
}

test_functionTypedParameter() async {
Expand Down Expand Up @@ -184,7 +184,7 @@ class C {
mixin C {
f() => 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 9)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 12, 1)]);
}

test_setter_topLevel() async {
Expand All @@ -196,23 +196,23 @@ set f(int x) => print(x);
test_topLevelArrowFunction() async {
await assertErrorsInCode(r'''
f() => 7;
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 9)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 1)]);
}

test_topLevelFunction() async {
await assertErrorsInCode(r'''
f() {
return 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 19)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 1)]);
}

test_topLevelFunction_async() async {
await assertErrorsInCode(r'''
f() {
return 7;
}
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 19)]);
''', [error(WarningCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE, 0, 1)]);
}

test_topLevelFunction_withReturnType() async {
Expand Down
Loading

0 comments on commit 8eaed33

Please sign in to comment.