-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
It is possible to have the following code without any warnings
extension on Never
{ int get instanceMember=>
0;
}
The instanceMember
declaration can never be usable and is guaranteed to be a dead declaration/code. It would be helpful if a static warning were displayed to notify developers. This is not a matter of correctness but enhancing developer experience and enforcing the semantics of Never
.
Warnings should not be reported for accessible static members e.g. the following should have no warning
extension A on Never
{ static void a()
{}
}
As @FMorschel stated in this thread, this also applies to extension types
e.g.
extension type A(Never n)
{}
Should produce a warning because the primary constructor can never be used. This would also apply to instance member declarations added to the extension type.
A somewhat related issue regarding reporting warnings for any usage of Never
objects can be found #60247. For more information see dart-lang/language#4279, it contains discussion related to this.