-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.model-messagesPoor/undesirable messaging in errors/warnings emitted by the analyzer and/or CFE.Poor/undesirable messaging in errors/warnings emitted by the analyzer and/or CFE.
Description
Consider:
other.dart:
class C {}
main.dart:
import 'other.dart' deferred as other;
void main() {
test(other.C.new);
}
void test(Object Function() f) {
print(f);
}
This provides no analyzer diagnostics (which is a known issue that applies to more situations), but the front end does error:
main.dart:4:16:
Error: 'new' can only be used as a constructor reference.
test(other.C.new);
^^^
Error: Compilation failed.
Most deferred errors will happen at runtime if you haven't imported the library with an explanation as to why, but this is happening at compile time, I'm assuming because the tear off is constant?
It's nice for it to happen at compile time, but the error isn't helpful for developers trying to resolve it since .new
is a constructor reference.
Side note: I discovered this issue since unnecessary_lambdas
made this change automatically (fix here).
ali-alizadeh
Metadata
Metadata
Assignees
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.model-messagesPoor/undesirable messaging in errors/warnings emitted by the analyzer and/or CFE.Poor/undesirable messaging in errors/warnings emitted by the analyzer and/or CFE.