dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.27k stars 1.58k forks source link

strict-inference does not report types with bound type parameters #52640

Open JCKodel opened 1 year ago

JCKodel commented 1 year ago

Describe the issue

While using this analysis_options.yaml:

analyzer:
  language:
    strict-casts: true
    strict-raw-types: true
    strict-inference: true

This example only triggers a warning in the first usage (while it should trigger for both):

class AnotherClass {}

class Something {
  void foo<T>() {}
  void bar<T extends AnotherClass> {}

  void tests() {
    foo(); // ⚠️ The type argument(s) of the function 'foo' can't be inferred.
    bar(); // No warnings
  }
}
srawlins commented 1 year ago

Thanks for filing an issue! This is a duplicate of https://github.com/dart-lang/sdk/issues/45372

eernstg commented 1 year ago

@JCKodel, I suggested a way to conceptualize the behavior of 'strict-raw-types' on https://github.com/dart-lang/sdk/issues/45372: One way to see it is that we're flagging types that contain dynamic implicitly, another way to see it is that we're flagging raw types in general. The actual behavior is to flag the former, not the latter.

However, in this case I think the relevant setting is 'strict-inference', not 'strict-raw-types' (there are no raw types in the example).

@srawlins, if this is true then maybe this isn't a duplicate of https://github.com/dart-lang/sdk/issues/45372 after all? I suppose the behavior of 'strict-raw-types' and the behavior of 'strict-inference' are two different topics?

srawlins commented 1 year ago

Good catch