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.2k stars 1.57k forks source link

[Analyzer] invalid_override: False positive on generic of generic in methods #47642

Closed lulupointu closed 2 years ago

lulupointu commented 2 years ago

The analyzer produces invalid_override on a valid override when using generic of generic in method.

class Page<T> {}

abstract class A {
  void a<P extends Page<T>, T>();
}

class B extends A {
  @override
  void a<P extends Page<T>, T>() {} // invalid_override
}

This does NOT happen for class definition:

class Page<T> {}

abstract class A<P extends Page<T>, T> {}

class B<P extends Page<T>, T> extends A<P, T> {}

dart --version Dart SDK version: 2.14.3 (stable) (Unknown timestamp) on "linux_x64"

Setup: Linux - Android studio ``` Android Studio 4.1.2 Build #AI-201.8743.12.41.7042882, built on December 20, 2020 Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 5.4.0-89-generic GC: ParNew, ConcurrentMarkSweep Memory: 3981M Cores: 8 Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true Non-Bundled Plugins: com.giancarlocode.built-value-snippets, com.bloc.intellij_generator_plugin, com.thoughtworks.gauge, com.vladsch.idea.multimarkdown, org.jetbrains.kotlin, com.xiaxiayige.fluter_assets_sync, de.tyxar.clean_architecture_plugin, PythonCore, SnakeCharm, Dart, io.flutter, de.mariushoefler.flutter_enhancement_suite, com.ixigua.flutter_asset_iteral, org.tbm98.flutter-riverpod-snippets Current Desktop: ubuntu:GNOME ```
srawlins commented 2 years ago

I can confirm dart accepts this; analyzer does not. 😦

scheglov commented 2 years ago

This code does not cause any compile-time errors reported in the bleeding edge analyzer. I vaguely remember fixing something related, but cannot find this CL. Anyway, it seems to be fixed now.