Migration: fix types of DecoratedType.{positional,named}Parameters

These fields can be `null`, but if they aren't, then the
`DecoratedType`s they contain cannot be `null`.

Change-Id: I9f07d06017ff9814e531f3517b4f452766dc0ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2022-08-17 17:32:04 +00:00 committed by Commit Bot
parent dfcf1e8a79
commit 53ed7a156a
5 changed files with 101 additions and 102 deletions

View file

@ -29,11 +29,11 @@ class DecoratedType implements DecoratedTypeInfo {
/// If `this` is a function type, the [DecoratedType] of each of its
/// positional parameters (including both required and optional positional
/// parameters).
final List<DecoratedType?>? positionalParameters;
final List<DecoratedType>? positionalParameters;
/// If `this` is a function type, the [DecoratedType] of each of its named
/// parameters.
final Map<String, DecoratedType?>? namedParameters;
final Map<String, DecoratedType>? namedParameters;
/// If `this` is a parameterized type, the [DecoratedType] of each of its
/// type parameters.
@ -67,7 +67,7 @@ class DecoratedType implements DecoratedTypeInfo {
assert(namedParameters![parameter.name]!.type == parameter.type);
namedParameterCount++;
} else {
assert(positionalParameters![positionalParameterCount]!.type ==
assert(positionalParameters![positionalParameterCount].type ==
parameter.type);
positionalParameterCount++;
}
@ -296,11 +296,10 @@ class DecoratedType implements DecoratedTypeInfo {
roles[rolePrefix] = node;
returnType?.recordRoles(roles, rolePrefix: '$rolePrefix/@r');
for (int i = 0; i < positionalParameters!.length; i++) {
positionalParameters![i]!
.recordRoles(roles, rolePrefix: '$rolePrefix/$i');
positionalParameters![i].recordRoles(roles, rolePrefix: '$rolePrefix/$i');
}
for (var entry in namedParameters!.entries) {
entry.value!.recordRoles(roles, rolePrefix: '$rolePrefix/${entry.key}');
entry.value.recordRoles(roles, rolePrefix: '$rolePrefix/${entry.key}');
}
for (int i = 0; i < typeArguments.length; i++) {
typeArguments[i]!.recordRoles(roles, rolePrefix: '$rolePrefix/$i');
@ -484,7 +483,7 @@ class DecoratedType implements DecoratedTypeInfo {
var undecoratedParameterType = i < numRequiredParameters
? undecoratedResult.normalParameterTypes[i]
: undecoratedResult.optionalParameterTypes[i - numRequiredParameters];
newPositionalParameters.add(positionalParameters![i]!
newPositionalParameters.add(positionalParameters![i]
._substitute(substitution, undecoratedParameterType));
}
var newNamedParameters = <String, DecoratedType>{};
@ -493,7 +492,7 @@ class DecoratedType implements DecoratedTypeInfo {
var undecoratedParameterType =
undecoratedResult.namedParameterTypes[name];
newNamedParameters[name] =
(entry.value!._substitute(substitution, undecoratedParameterType));
(entry.value._substitute(substitution, undecoratedParameterType));
}
return DecoratedType(undecoratedResult, node,
returnType:

View file

@ -2504,7 +2504,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
assert(compoundOperatorType.positionalParameters!.isNotEmpty);
_checkAssignment(edgeOrigin, FixReasonTarget.root,
source: sourceType,
destination: compoundOperatorType.positionalParameters![0]!,
destination: compoundOperatorType.positionalParameters![0],
hard: _shouldUseHardEdge(expression!),
sourceIsFunctionLiteral: expression is FunctionExpression);
sourceType = _fixNumericTypes(compoundOperatorType.returnType!,
@ -2757,7 +2757,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
} else {
assert(method.isSetter);
DecoratedType currentParameterType =
_currentFunctionType!.positionalParameters!.single!;
_currentFunctionType!.positionalParameters!.single;
DecoratedType overriddenParameterType = overriddenFieldType;
_checkAssignment(
ParameterInheritanceOrigin(source, node), FixReasonTarget.root,
@ -2984,7 +2984,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
_checkAssignment(
GetterSetterCorrespondenceOrigin(source, node), FixReasonTarget.root,
source: getType!.substitute(getterSubstitution),
destination: setType!.substitute(setterSubstitution),
destination: setType.substitute(setterSubstitution),
hard: true);
}
@ -3099,7 +3099,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
// Any parameters not supplied must be optional.
for (var entry in calleeType.namedParameters!.entries) {
if (suppliedNamedParameters.contains(entry.key)) continue;
entry.value!.node!.recordNamedParameterNotSupplied(
entry.value.node!.recordNamedParameterNotSupplied(
_guards, _graph, NamedParameterNotSuppliedOrigin(source, node));
}
return calleeType.returnType;
@ -3294,13 +3294,13 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
i < y!.positionalParameters!.length;
i++) {
_linkDecoratedTypes(
x.positionalParameters![i]!, y.positionalParameters![i], origin,
x.positionalParameters![i], y.positionalParameters![i], origin,
isUnion: isUnion);
}
for (var entry in x.namedParameters!.entries) {
var superParameterType = y!.namedParameters![entry.key];
if (superParameterType != null) {
_linkDecoratedTypes(entry.value!, y.namedParameters![entry.key], origin,
_linkDecoratedTypes(entry.value, y.namedParameters![entry.key], origin,
isUnion: isUnion);
}
}
@ -3808,15 +3808,15 @@ mixin _AssignmentChecker {
i++) {
// Note: source and destination are swapped due to contravariance.
_checkAssignment(origin, edgeTarget.positionalParameter(i),
source: destination.positionalParameters![i]!,
destination: source.positionalParameters![i]!,
source: destination.positionalParameters![i],
destination: source.positionalParameters![i],
hard: false,
checkable: false);
}
for (var entry in destination.namedParameters!.entries) {
// Note: source and destination are swapped due to contravariance.
_checkAssignment(origin, edgeTarget.namedParameter(entry.key),
source: entry.value!,
source: entry.value,
destination: source.namedParameters![entry.key]!,
hard: false,
checkable: false);

View file

@ -45,12 +45,12 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
/// If the parameters of a function or method are being visited, the
/// [DecoratedType]s of the function's named parameters that have been seen so
/// far. Otherwise `null`.
Map<String, DecoratedType?>? _namedParameters;
Map<String, DecoratedType>? _namedParameters;
/// If the parameters of a function or method are being visited, the
/// [DecoratedType]s of the function's positional parameters that have been
/// seen so far. Otherwise `null`.
List<DecoratedType?>? _positionalParameters;
List<DecoratedType>? _positionalParameters;
/// If the child types of a node are being visited, the
/// [NullabilityNodeTarget] that should be used in [visitTypeAnnotation].
@ -456,7 +456,7 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
soft: true);
if (_getAngularAnnotation(node.metadata) == _AngularAnnotation.child) {
_graph.makeNullable(
type!.node!, AngularAnnotationOrigin(source, node));
type.node!, AngularAnnotationOrigin(source, node));
}
}
}
@ -530,8 +530,8 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
}
var typeArguments = const <DecoratedType>[];
DecoratedType? decoratedReturnType;
List<DecoratedType?> positionalParameters = const <DecoratedType>[];
Map<String, DecoratedType?> namedParameters =
List<DecoratedType> positionalParameters = const <DecoratedType>[];
Map<String, DecoratedType> namedParameters =
const <String, DecoratedType>{};
if (type is InterfaceType && type.element2.typeParameters.isNotEmpty) {
if (node is NamedType) {
@ -567,8 +567,8 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
decoratedReturnType = returnType.accept(this);
});
}
positionalParameters = <DecoratedType?>[];
namedParameters = <String, DecoratedType?>{};
positionalParameters = <DecoratedType>[];
namedParameters = <String, DecoratedType>{};
var previousPositionalParameters = _positionalParameters;
var previousNamedParameters = _namedParameters;
try {
@ -823,8 +823,8 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
_unimplemented(
typeParameters, 'Function-typed parameter with type parameters');
}
var positionalParameters = <DecoratedType?>[];
var namedParameters = <String, DecoratedType?>{};
var positionalParameters = <DecoratedType>[];
var namedParameters = <String, DecoratedType>{};
var previousPositionalParameters = _positionalParameters;
var previousNamedParameters = _namedParameters;
try {
@ -853,9 +853,9 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
}
}
if (declaredElement.isNamed) {
_namedParameters![declaredElement.name] = decoratedType;
_namedParameters![declaredElement.name] = decoratedType!;
} else {
_positionalParameters!.add(decoratedType);
_positionalParameters!.add(decoratedType!);
}
return decoratedType;
}

View file

@ -169,7 +169,7 @@ class AssignmentCheckerTest extends Object
assign(t1, t2, hard: true);
// Note: t1 and t2 are swapped due to contravariance.
assertEdge(
t2.positionalParameters![0]!.node, t1.positionalParameters![0]!.node,
t2.positionalParameters![0].node, t1.positionalParameters![0].node,
hard: false, checkable: false);
}
@ -186,7 +186,7 @@ class AssignmentCheckerTest extends Object
assign(t1, t2, hard: true);
// Note: t1 and t2 are swapped due to contravariance.
assertEdge(
t2.positionalParameters![0]!.node, t1.positionalParameters![0]!.node,
t2.positionalParameters![0].node, t1.positionalParameters![0].node,
hard: false, checkable: false);
}
@ -196,7 +196,7 @@ class AssignmentCheckerTest extends Object
assign(t1, t2);
// Note: t1 and t2 are swapped due to contravariance.
assertEdge(
t2.positionalParameters![0]!.node, t1.positionalParameters![0]!.node,
t2.positionalParameters![0].node, t1.positionalParameters![0].node,
hard: false, checkable: false);
}
@ -2034,7 +2034,7 @@ D f(MyList<int>/*2*/ x) => D(x);
''');
var syntheticConstructor = findElement.unnamedConstructor('D');
var constructorType = variables.decoratedElementType(syntheticConstructor);
var constructorParameterType = constructorType.positionalParameters![0]!;
var constructorParameterType = constructorType.positionalParameters![0];
assertEdge(decoratedTypeAnnotation('MyList<int>/*2*/').node,
constructorParameterType.node,
hard: true);
@ -2058,7 +2058,7 @@ class D<U> = C<U> with M;
''');
var syntheticConstructor = findElement.unnamedConstructor('D');
var constructorType = variables.decoratedElementType(syntheticConstructor);
var constructorParameterType = constructorType.positionalParameters![0]!;
var constructorParameterType = constructorType.positionalParameters![0];
assertUnion(
constructorParameterType.node, decoratedTypeAnnotation('T t').node);
}
@ -2095,7 +2095,7 @@ D f(int/*2*/ i) => D(i);
''');
var syntheticConstructor = findElement.unnamedConstructor('D');
var constructorType = variables.decoratedElementType(syntheticConstructor);
var constructorParameterType = constructorType.positionalParameters![0]!;
var constructorParameterType = constructorType.positionalParameters![0];
assertEdge(
decoratedTypeAnnotation('int/*2*/').node, constructorParameterType.node,
hard: true);
@ -2115,7 +2115,7 @@ D f(int/*2*/ i) => D(i);
''');
var syntheticConstructor = findElement.unnamedConstructor('D');
var constructorType = variables.decoratedElementType(syntheticConstructor);
var constructorParameterType = constructorType.positionalParameters![0]!;
var constructorParameterType = constructorType.positionalParameters![0];
assertEdge(
decoratedTypeAnnotation('int/*2*/').node, constructorParameterType.node,
hard: true);
@ -2185,9 +2185,9 @@ void f(bool b, void Function(int) x, void Function(int) y) {
var resultType = decoratedExpressionType('(b ?')!;
assertLUB(resultType.node!, xType.node, yType.node);
assertGLB(
resultType.positionalParameters![0]!.node,
xType.positionalParameters![0]!.node,
yType.positionalParameters![0]!.node);
resultType.positionalParameters![0].node,
xType.positionalParameters![0].node,
yType.positionalParameters![0].node);
}
Future<void>
@ -2204,13 +2204,13 @@ void f(bool b, void Function(int, int) x, void Function(int, int) y) {
var resultType = decoratedExpressionType('(b ?')!;
assertLUB(resultType.node!, xType.node, yType.node);
assertGLB(
resultType.positionalParameters![0]!.node,
xType.positionalParameters![0]!.node,
yType.positionalParameters![0]!.node);
resultType.positionalParameters![0].node,
xType.positionalParameters![0].node,
yType.positionalParameters![0].node);
assertGLB(
resultType.positionalParameters![1]!.node,
xType.positionalParameters![1]!.node,
yType.positionalParameters![1]!.node);
resultType.positionalParameters![1].node,
xType.positionalParameters![1].node,
yType.positionalParameters![1].node);
}
Future<void>
@ -2227,9 +2227,9 @@ void f(bool b, void Function([int]) x, void Function([int]) y) {
var resultType = decoratedExpressionType('(b ?')!;
assertLUB(resultType.node!, xType.node, yType.node);
assertGLB(
resultType.positionalParameters![0]!.node,
xType.positionalParameters![0]!.node,
yType.positionalParameters![0]!.node);
resultType.positionalParameters![0].node,
xType.positionalParameters![0].node,
yType.positionalParameters![0].node);
}
Future<void> test_conditionalExpression_functionTyped_returnType() async {
@ -2458,9 +2458,9 @@ void f(bool b, void Function(Null p) x, void Function(List<int> p) y) {
var resultType = decoratedExpressionType('(b ?')!;
assertLUB(resultType.node!, xType.node, yType.node);
assertGLB(
resultType.positionalParameters![0]!.node,
xType.positionalParameters![0]!.node,
yType.positionalParameters![0]!.node);
resultType.positionalParameters![0].node,
xType.positionalParameters![0].node,
yType.positionalParameters![0].node);
}
Future<void> test_conditionalExpression_parameterType() async {
@ -2677,7 +2677,7 @@ class D extends C {
var namedConstructor = findElement.constructor('named', of: 'C');
var constructorType = variables.decoratedElementType(namedConstructor);
var constructorParameterType = constructorType.positionalParameters![0]!;
var constructorParameterType = constructorType.positionalParameters![0];
assertEdge(
decoratedTypeAnnotation('int j').node, constructorParameterType.node,
hard: true);
@ -3184,13 +3184,13 @@ class C {
''');
var ctorParamType = variables
.decoratedElementType(findElement.unnamedConstructor('C'))
.positionalParameters![0]!;
.positionalParameters![0];
var fieldType = variables.decoratedElementType(findElement.field('f'));
assertEdge(ctorParamType.node, fieldType.node, hard: true);
assertEdge(ctorParamType.returnType!.node, fieldType.returnType!.node,
hard: false, checkable: false);
assertEdge(fieldType.positionalParameters![0]!.node,
ctorParamType.positionalParameters![0]!.node,
assertEdge(fieldType.positionalParameters![0].node,
ctorParamType.positionalParameters![0].node,
hard: false, checkable: false);
assertEdge(fieldType.namedParameters!['j']!.node,
ctorParamType.namedParameters!['j']!.node,
@ -3217,7 +3217,7 @@ class C {
}
''');
var decoratedConstructorParamType =
decoratedConstructorDeclaration('named').positionalParameters![0]!;
decoratedConstructorDeclaration('named').positionalParameters![0];
assertEdge(decoratedConstructorParamType.node,
decoratedTypeAnnotation('int i').node,
hard: true);
@ -4700,8 +4700,8 @@ class C extends B {
void f/*C*/(x) {}
}
''');
var bReturnType = decoratedMethodType('f/*B*/').positionalParameters![0]!;
var cReturnType = decoratedMethodType('f/*C*/').positionalParameters![0]!;
var bReturnType = decoratedMethodType('f/*B*/').positionalParameters![0];
var cReturnType = decoratedMethodType('f/*C*/').positionalParameters![0];
assertEdge(bReturnType.node, cReturnType.node, hard: true);
}
@ -5093,7 +5093,7 @@ void f(List<int> x, int i) {
findNode.methodInvocation('x.add').methodName.staticElement!;
var nullable_t = variables
.decoratedElementType(addMethod.declaration!)
.positionalParameters![0]!
.positionalParameters![0]
.node;
assertEdge(nullable_t, never, hard: true, checkable: false);
var check_i = checkExpression('i/*check*/')!;
@ -6616,8 +6616,8 @@ int Function(int) g(C c) => c.f;
variables.decoratedElementType(findElement.function('g')).returnType!;
assertEdge(fType.returnType!.node, gReturnType.returnType!.node,
hard: false, checkable: false);
assertEdge(gReturnType.positionalParameters![0]!.node,
fType.positionalParameters![0]!.node,
assertEdge(gReturnType.positionalParameters![0].node,
fType.positionalParameters![0].node,
hard: false, checkable: false);
}
@ -7709,8 +7709,8 @@ int Function(int) g() => f;
variables.decoratedElementType(findElement.function('g')).returnType!;
assertEdge(fType.returnType!.node, gReturnType.returnType!.node,
hard: false, checkable: false);
assertEdge(gReturnType.positionalParameters![0]!.node,
fType.positionalParameters![0]!.node,
assertEdge(gReturnType.positionalParameters![0].node,
fType.positionalParameters![0].node,
hard: false, checkable: false);
}
@ -7726,8 +7726,8 @@ abstract class C {
variables.decoratedElementType(findElement.method('g')).returnType!;
assertEdge(fType.returnType!.node, gReturnType.returnType!.node,
hard: false, checkable: false);
assertEdge(gReturnType.positionalParameters![0]!.node,
fType.positionalParameters![0]!.node,
assertEdge(gReturnType.positionalParameters![0].node,
fType.positionalParameters![0].node,
hard: false, checkable: false);
}

View file

@ -138,8 +138,8 @@ class D = C with M;
_assertType(aType.returnType!.type!, 'D');
expect(aType.returnType!.node, same(never));
expect(aType.positionalParameters, hasLength(1));
_assertType(aType.positionalParameters![0]!.type!, 'int');
expect(aType.positionalParameters![0]!.node,
_assertType(aType.positionalParameters![0].type!, 'int');
expect(aType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
expect(aType.namedParameters, isEmpty);
var b = findElement.constructor('b', of: 'D');
@ -150,8 +150,8 @@ class D = C with M;
_assertType(bType.returnType!.type!, 'D');
expect(bType.returnType!.node, same(never));
expect(bType.positionalParameters, hasLength(1));
_assertType(bType.positionalParameters![0]!.type!, 'int');
expect(bType.positionalParameters![0]!.node,
_assertType(bType.positionalParameters![0].type!, 'int');
expect(bType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
expect(bType.namedParameters, isEmpty);
var c = findElement.constructor('c', of: 'D');
@ -175,12 +175,12 @@ class D = C with M;
_assertType(dType.returnType!.type!, 'D');
expect(dType.returnType!.node, same(never));
expect(dType.positionalParameters, hasLength(1));
_assertType(dType.positionalParameters![0]!.type!, 'List<int>');
expect(dType.positionalParameters![0]!.node,
_assertType(dType.positionalParameters![0].type!, 'List<int>');
expect(dType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
expect(dType.positionalParameters![0]!.typeArguments, hasLength(1));
_assertType(dType.positionalParameters![0]!.typeArguments[0]!.type!, 'int');
expect(dType.positionalParameters![0]!.typeArguments[0]!.node,
expect(dType.positionalParameters![0].typeArguments, hasLength(1));
_assertType(dType.positionalParameters![0].typeArguments[0]!.type!, 'int');
expect(dType.positionalParameters![0].typeArguments[0]!.node,
TypeMatcher<NullabilityNodeMutable>());
expect(dType.namedParameters, isEmpty);
}
@ -207,8 +207,8 @@ class D<U> = C<U> with M;
expect(typeArguments[0]!.node, same(never));
var dParams = dConstructorType.positionalParameters!;
expect(dParams, hasLength(1));
_assertType(dParams[0]!.type!, 'U');
expect(dParams[0]!.node, TypeMatcher<NullabilityNodeMutable>());
_assertType(dParams[0].type!, 'U');
expect(dParams[0].node, TypeMatcher<NullabilityNodeMutable>());
}
Future<void> test_class_with_default_constructor() async {
@ -796,8 +796,8 @@ class C {
var ctorParamType = variables.decoratedElementType(ctorParam);
expect(ctorType.positionalParameters![0], same(ctorParamType));
expect(ctorParamType.node, TypeMatcher<NullabilityNodeMutable>());
_assertType(ctorParamType.positionalParameters![0]!.type!, 'dynamic');
expect(ctorParamType.positionalParameters![0]!.node!.isImmutable, false);
_assertType(ctorParamType.positionalParameters![0].type!, 'dynamic');
expect(ctorParamType.positionalParameters![0].node!.isImmutable, false);
}
Future<void> test_fieldFormalParameter_function_return_typed() async {
@ -897,7 +897,7 @@ class C {
}
''');
var decoratedConstructorParamType =
decoratedConstructorDeclaration('named').positionalParameters![0]!;
decoratedConstructorDeclaration('named').positionalParameters![0];
expect(decoratedTypeAnnotation('int this'),
same(decoratedConstructorParamType));
_assertType(decoratedConstructorParamType.type!, 'int');
@ -915,7 +915,7 @@ class C {
}
''');
var decoratedConstructorParamType =
decoratedConstructorDeclaration('named').positionalParameters![0]!;
decoratedConstructorDeclaration('named').positionalParameters![0];
_assertType(decoratedConstructorParamType.type!, 'int');
expect(decoratedConstructorParamType.node,
TypeMatcher<NullabilityNodeMutable>());
@ -1071,10 +1071,10 @@ typedef T F<T, U>(U u);
expect(
decoratedType.returnType!.node, TypeMatcher<NullabilityNodeMutable>());
expect(
(decoratedType.positionalParameters![0]!.type as TypeParameterType)
(decoratedType.positionalParameters![0].type as TypeParameterType)
.element2,
same(u));
expect(decoratedType.positionalParameters![0]!.node,
expect(decoratedType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
}
@ -1177,8 +1177,8 @@ void f(void g(i)) {}
var gType = variables.decoratedElementType(g);
expect(fType.positionalParameters![0], same(gType));
expect(gType.node, TypeMatcher<NullabilityNodeMutable>());
_assertType(gType.positionalParameters![0]!.type!, 'dynamic');
expect(gType.positionalParameters![0]!.node!.isImmutable, false);
_assertType(gType.positionalParameters![0].type!, 'dynamic');
expect(gType.positionalParameters![0].node!.isImmutable, false);
}
Future<void> test_functionTypedFormalParameter_return_typed() async {
@ -1223,7 +1223,7 @@ void f(T Function<T, U>(U) x) {}
expect((decoratedType.returnType!.type as TypeParameterType).element2,
same(t));
expect(
(decoratedType.positionalParameters![0]!.type as TypeParameterType)
(decoratedType.positionalParameters![0].type as TypeParameterType)
.element2,
same(u));
}
@ -1305,10 +1305,10 @@ typedef F = T Function<T, U>(U u);
expect(
decoratedType.returnType!.node, TypeMatcher<NullabilityNodeMutable>());
expect(
(decoratedType.positionalParameters![0]!.type as TypeParameterType)
(decoratedType.positionalParameters![0].type as TypeParameterType)
.element2,
same(u));
expect(decoratedType.positionalParameters![0]!.node,
expect(decoratedType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
}
@ -1332,10 +1332,10 @@ typedef F<T, U> = T Function(U u);
expect(
decoratedType.returnType!.node, TypeMatcher<NullabilityNodeMutable>());
expect(
(decoratedType.positionalParameters![0]!.type as TypeParameterType)
(decoratedType.positionalParameters![0].type as TypeParameterType)
.element2,
same(u));
expect(decoratedType.positionalParameters![0]!.node,
expect(decoratedType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
}
@ -1645,7 +1645,7 @@ class C {
void f(x) {}
}
''');
var decoratedType = decoratedMethodType('f').positionalParameters![0]!;
var decoratedType = decoratedMethodType('f').positionalParameters![0];
expect(decoratedType.node!.isImmutable, false);
}
@ -1668,7 +1668,7 @@ class C extends B {
void f/*C*/(x) {}
}
''');
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0]!;
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0];
expect(decoratedType.node, TypeMatcher<NullabilityNodeMutable>());
}
@ -1681,7 +1681,7 @@ class C extends B {
void f/*C*/(x) {}
}
''');
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0]!;
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0];
expect(decoratedType.node!.isImmutable, false);
}
@ -1709,8 +1709,8 @@ class C extends B {
}
''');
var decoratedBaseType =
decoratedMethodType('f/*B*/').positionalParameters![0]!;
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0]!;
decoratedMethodType('f/*B*/').positionalParameters![0];
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0];
var decoratedTypeFormalBound = decoratedTypeParameterBounds
.get((decoratedType.type as FunctionType).typeFormals[0])!;
_assertType(decoratedTypeFormalBound.type!, 'Object');
@ -1731,8 +1731,8 @@ class C extends B {
}
''');
var decoratedBaseType =
decoratedMethodType('f/*B*/').positionalParameters![0]!;
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0]!;
decoratedMethodType('f/*B*/').positionalParameters![0];
var decoratedType = decoratedMethodType('f/*C*/').positionalParameters![0];
var decoratedTypeFormalBound = decoratedTypeParameterBounds
.get((decoratedType.type as FunctionType).typeFormals[0])!;
_assertType(decoratedTypeFormalBound.type!, 'num');
@ -2140,12 +2140,12 @@ F f;
'return type of F (test.dart:1:9)');
expect(decoratedType.returnType!.node!.displayName,
'return type of f (test.dart:2:1)');
_assertType(decoratedType.positionalParameters![0]!.type!, 'String');
expect(decoratedType.positionalParameters![0]!.node,
_assertType(decoratedType.positionalParameters![0].type!, 'String');
expect(decoratedType.positionalParameters![0].node,
TypeMatcher<NullabilityNodeMutable>());
expect(decoratedType.positionalParameters![0]!.node,
isNot(same(typedefDecoratedType.positionalParameters![0]!.node)));
expect(decoratedType.positionalParameters![0]!.node!.displayName,
expect(decoratedType.positionalParameters![0].node,
isNot(same(typedefDecoratedType.positionalParameters![0].node)));
expect(decoratedType.positionalParameters![0].node!.displayName,
'parameter 0 of f (test.dart:2:1)');
}
@ -2173,9 +2173,9 @@ F f;
// This is necessary because there is no guarantee of whether the typedef or
// its usage will be visited first.
var decoratedType = decoratedTypeAnnotation('F f');
expect(decoratedType.positionalParameters![0]!.node!.displayName,
expect(decoratedType.positionalParameters![0].node!.displayName,
'parameter 0 of f (test.dart:2:1)');
expect(decoratedType.positionalParameters![1]!.node!.displayName,
expect(decoratedType.positionalParameters![1].node!.displayName,
'parameter 1 of f (test.dart:2:1)');
}