mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
Issue 27098. Check that argument is assignable to parameter in call().
R=brianwilkerson@google.com Bug: https://github.com/dart-lang/sdk/issues/27098 Change-Id: I0d5ac65202b632646bd7b26170c55ab985d2523c Reviewed-on: https://dart-review.googlesource.com/52263 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
be47fa67aa
commit
6865041334
|
@ -95,7 +95,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
/**
|
||||
* The version of data format, should be incremented on every format change.
|
||||
*/
|
||||
static const int DATA_VERSION = 56;
|
||||
static const int DATA_VERSION = 57;
|
||||
|
||||
/**
|
||||
* The number of exception contexts allowed to write. Once this field is
|
||||
|
|
|
@ -658,6 +658,21 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
|||
DartType staticType = _resolver.strongMode
|
||||
? _getStaticTypeOrFunctionType(target)
|
||||
: _getStaticType(target);
|
||||
|
||||
if (_resolver.strongMode &&
|
||||
staticType is FunctionType &&
|
||||
methodName.name == FunctionElement.CALL_METHOD_NAME) {
|
||||
if (target is SimpleIdentifier) {
|
||||
methodName.staticElement = target.staticElement;
|
||||
}
|
||||
methodName.staticType = target.staticType;
|
||||
node.staticType = staticType;
|
||||
node.staticInvokeType = staticType;
|
||||
node.argumentList.correspondingStaticParameters =
|
||||
_computeCorrespondingParameters(node.argumentList, staticType);
|
||||
return null;
|
||||
}
|
||||
|
||||
DartType propagatedType = _getPropagatedType(target);
|
||||
staticElement = _resolveInvokedElementWithTarget(
|
||||
target, staticType, methodName, isConditional);
|
||||
|
|
|
@ -368,6 +368,20 @@ f(A a) {
|
|||
verify([source]);
|
||||
}
|
||||
|
||||
test_argumentTypeNotAssignable_call() async {
|
||||
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
|
||||
Source source = addSource(r'''
|
||||
typedef bool Predicate<T>(T object);
|
||||
|
||||
Predicate<String> f() => null;
|
||||
|
||||
void main() {
|
||||
f().call(3);
|
||||
}''');
|
||||
await computeAnalysisResult(source);
|
||||
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
||||
}
|
||||
|
||||
test_argumentTypeNotAssignable_cascadeSecond() async {
|
||||
Source source = addSource(r'''
|
||||
// filler filler filler filler filler filler filler filler filler filler
|
||||
|
|
Loading…
Reference in a new issue