linter icon indicating copy to clipboard operation
linter copied to clipboard

unnecessary_overrides does not work for generic methods and null safety mix

Open scheglov opened this issue 5 years ago • 1 comments

The lint is not reported for:

class A<T> {
  T foo() {
    throw 42;
  }
}

class B extends A<int> {
  @override
  int foo() => super.foo();
}

This is a failing test from analysis server.

  Future<void> test_method_nullSafety_optIn_fromOptOut() async {
    createAnalysisOptionsFile(
      experiments: ['non-nullable'],
      lints: [lintCode],
    );
    newFile('/home/test/lib/a.dart', content: r'''
class A {
  int foo() => 0;
}
''');
    await resolveTestUnit('''
// @dart = 2.7
import 'a.dart';

class B extends A {
  @override
  int foo() => super.foo();
}
''');
    await assertHasFix('''
// @dart = 2.7
import 'a.dart';

class B extends A {
}
''');
  }

scheglov avatar Feb 05 '20 19:02 scheglov

Thanks! I've got this reproduced and see the problem. 👍

pq avatar Feb 06 '20 14:02 pq