sdk
sdk copied to clipboard
IDEs pick wrong context when using dot shorthands with operator `!=`
(To be clear, this is purely an issue with live analysis, like DartCode and DartPad. When the code is fully written the compiler behaves correctly.)
Given the following example:
enum Example { one, two, three }
void main() {
var example = Example.one;
if (example != . ) {
// ^ caret here
}
}
Requesting code completion (IntelliSense) after example != . will suggest entries from a context type of Object: .new(), .hash(), .hashAll(), .hashAllUnordered(), which once entered are promptly rejected by the analyzer as they are not valid.
If the operator is replaced with ==, the proper context type of Example is picked, resulting in the expected suggestions of .one, .two, .three, and .values.
Dart version:
Dart SDK version: 3.10.3 (stable) (Tue Dec 2 01:04:53 2025 -0800) on "macos_arm64"
DartPad:
Based on Dart SDK 3.10.1 and Flutter SDK 3.38.3