Fix ParameterElementImpl.hasImplicitType for function-typed parameters.

UnlinkedParam.type serves a dual role: for ordinary parameters it is
the declared type; for function-typed parameters it is the declared
return type.  So to determine whether a parameter has an implicit type
it is not sufficient to check whether UnlinkedParam.type is `null`.
We also need to check whether the parameter is function-typed.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2947703002 .
This commit is contained in:
Paul Berry 2017-06-19 13:13:51 -07:00
parent b5cff3f68f
commit e8131d6f1a
2 changed files with 9 additions and 1 deletions

View file

@ -7449,7 +7449,7 @@ class ParameterElementImpl extends VariableElementImpl
@override
bool get hasImplicitType {
if (_unlinkedParam != null) {
return _unlinkedParam.type == null;
return _unlinkedParam.type == null && !_unlinkedParam.isFunctionTyped;
}
return super.hasImplicitType;
}

View file

@ -8417,6 +8417,14 @@ void f<T, U>((U) → T x) {}
}
}
test_function_typed_parameter_implicit() {
var library = checkLibrary('f(g()) => null;');
expect(
library
.definingCompilationUnit.functions[0].parameters[0].hasImplicitType,
isFalse);
}
test_functions() {
var library = checkLibrary('f() {} g() {}');
if (isStrongMode) {