-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-serverIssues related to some aspect of the analysis serverIssues related to some aspect of the analysis servertype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
This was originally raised at Dart-Code/Dart-Code#5366 by @klukshu.
Given:
a.dart
sealed class Attribute {}
class Attribute1 extends Attribute {}
class Attribute2 extends Attribute {}
switch.dart
import 'a.dart';
Object? f(Attribute attribute) {
return switch (attribute) {
Attribute1() => throw UnimplementedError(),
Attribute2() => throw UnimplementedError(),
};
}
class Attribute1 {}
The Attribute1 in the switch case is not the correct one (this produces no warning - which is #56338), but using the quick fix to "Add missing switch cases" adds code that does the same:
return switch (attribute) {
Attribute1() => throw UnimplementedError(),
Attribute2() => throw UnimplementedError(),
// TODO: Handle this case.
Attribute1() => throw UnimplementedError(),
};
This results in the original diagnostic (not exhaustively matched) remaining, but an additional one for "this case is covered by previous cases").
I'm not sure what the right fix is though, probably it would require adding an import with a prefix, but I'm not sure if that's the fix the user would want?
FMorschel
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-serverIssues related to some aspect of the analysis serverIssues related to some aspect of the analysis servertype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)