-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone
Description
The analyzer doesn't catch this static type error:
void foo(bool callback()) { }
class Bar {
void callFoo() {
foo(method); // <-- this call is illegal ("method" has the wrong signature)
}
void method() { }
}
void main() {
new Bar().callFoo();
}
Analyzer output:
lint • Document all public members at test.dart:1:6 • public_member_api_docs
lint • Document all public members at test.dart:3:7 • public_member_api_docs
lint • Document all public members at test.dart:4:8 • public_member_api_docs
lint • Document all public members at test.dart:8:8 • public_member_api_docs
VM output (checked mode):
Unhandled exception:
type '() => void' is not a subtype of type '() => bool' of 'callback'
#0 foo (test.dart:1:15)
#1 Bar.callFoo (test.dart:5:5)
#2 main (test.dart:12:13)
#3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
The analyzer does catch the problem if I make callFoo
and method
top-level functions or statics on the Bar class. It's only if they're methods that it's a problem.
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)