Skip to content

implicit-downcasts in analysis_options doesn't work #27622

Closed
@nex3

Description

@nex3

If I have the following .analysis_options file:

analyzer:
  strong-mode:
  - implicit-downcasts: false
  - implicit-dynamic: false

and the following Dart file (taken from this example):

// test.dart

void main() {
  Object o = new Object();
  String s = o;  // Implicit downcast
  String s2 = s.substring(1);
}

and I run dartanalyzer test.dart, it only reports:

[hint] The value of the local variable 's2' is not used

The same is true if I run dartanalyzer --strong --no-implicit-casts test.dart. However, if I delete .analysis_options and run dartanalyzer --strong --no-implicit-casts test.dart, I get:

[error] A value of type 'Object' cannot be assigned to a variable of type 'String'
[hint] The value of the local variable 's2' is not used

I've tested this against Dart 1.20.1 and 1.19.0. I think the implicit-dynamic flag has the same issue, but I don't know of a simple file to test it on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ondevexp-commandIssues with the command-line dartanalyzer toollegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions