Skip to content

Analyzer does not throw a error when a class implements some class and its alias #45526

@iarkh

Description

@iarkh

Dart SDK version: 2.13.0-165.0.dev (dev) (Thu Mar 25 02:53:52 2021 -0700) on "windows_x64"

Here is a source code example which demonstrates the problem:

abstract class I {}
abstract class J {}

typedef IAlias = I;

class A implements I, J, IAlias {}

main() {}

Dart throws a compile error whereas analyzer silently passes here.

It is a compile-time error if the implements clause of a class C specifies a type T as a superinterface more than once, so seems like analyzer should throw an exception too.

Sample output is:

$> dartanalyzer --enable-experiment=nonfunction-type-aliases test.dart
Analyzing test.dart...
No issues found!

$> dart --enable-experiment=nonfunction-type-aliases test.dart
test.dart: Error: 'I' can only be implemented once.
Try removing 1 of the occurrences.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onlanguage-nonfunction-type-aliasesIssues related to non-function type aliaseslegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions