Skip to content

Analyzer throws exception if function optional argument is omitted and it's parametrized. #33864

Closed
@iarkh

Description

@iarkh

Dart SDK Version: 2.0.0_dev.68.0
OS: Windows 10

The following sample code example declares a function with one optional parametrized argument and than calls it without parameters:

class A<X> {}
testme<X extends A<X>>([X x]) {}

main() { testme(); }

It passes with dart and it seems like a correct result - indeed, if we don't set optional input argument, it should not affect the execution.
However, dartanalyzer throws an error here:

Analyzing test.dart...
  error - Couldn't infer type parameter 'X'.

Tried to infer 'A<dynamic>' for 'X' which doesn't work:
  Type parameter 'X' declared to extend 'A<A<dynamic>>'.

Consider passing explicit type argument(s) to the generic.

 at test.dart:4:10 - strong_mode_could_not_infer
1 error found.

I suppose analyzer should pass here too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4dart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions