File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
pkg/analyzer/lib/src/dart/resolver Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,15 @@ class FunctionExpressionResolver {
9494 // Check that there is no declared type, and that we have not already
9595 // inferred a type in some fashion.
9696 if (p.hasImplicitType && (p.type == null || p.type.isDynamic)) {
97+ // If no type is declared for a parameter and there is a
98+ // corresponding parameter in the context type schema with type
99+ // schema `K`, the parameter is given an inferred type `T` where `T`
100+ // is derived from `K` as follows.
97101 inferredType = _typeSystem.greatestClosure (inferredType);
98- if (inferredType.isDartCoreNull || inferredType is NeverTypeImpl ) {
102+
103+ // If the greatest closure of `K` is `S` and `S` is a subtype of
104+ // `Null`, then `T` is `Object?`. Otherwise, `T` is `S`.
105+ if (_typeSystem.isSubtypeOf2 (inferredType, _typeSystem.nullNone)) {
99106 inferredType = _isNonNullableByDefault
100107 ? _typeSystem.objectQuestion
101108 : _typeSystem.objectStar;
You can’t perform that action at this time.
0 commit comments