Skip to content

Commit dac4797

Browse files
authored
[ffigen] Remove Parameter.isCovariant (#2842)
1 parent 77c2e52 commit dac4797

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

pkgs/ffigen/lib/src/code_generator/func.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ class Parameter extends AstNode {
239239
final String originalName;
240240
Type type;
241241
final bool objCConsumed;
242-
bool isCovariant = false;
243242

244243
Symbol symbol;
245244
String get name => symbol.name;

pkgs/ffigen/lib/src/visitor/fix_overridden_methods.dart

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -92,61 +92,12 @@ class FixOverriddenMethodsVisitation extends Visitation {
9292
}
9393
}
9494

95-
void _fixCoavariantArgs(
96-
ObjCInterface node,
97-
ObjCMethod method,
98-
ObjCInterface superType,
99-
ObjCMethod superMethod,
100-
) {
101-
// In Dart, method arg types are contravariant, but ObjC allows them to be
102-
// covariant. So fix these cases by adding the `covariant` keyword to the
103-
// parameter.
104-
final logger = context.logger;
105-
final n = method.params.length;
106-
if (n != superMethod.params.length) {
107-
logger.severe(
108-
'${node.originalName} is a subtype of ${superType.originalName} but '
109-
'their ${method.originalName} methods have a different number of '
110-
'parameters',
111-
);
112-
return;
113-
}
114-
115-
for (var i = 0; i < n; ++i) {
116-
final pt = method.params.elementAt(i).type;
117-
final st = superMethod.params.elementAt(i).type;
118-
119-
if (st.isSubtypeOf(pt)) {
120-
// Contravariant param, nothing to fix.
121-
continue;
122-
}
123-
124-
if (!pt.isSubtypeOf(st)) {
125-
// Types are unrelated, so this can't be sensibly fixed.
126-
logger.severe(
127-
'${node.originalName} is a subtype of ${superType.originalName} '
128-
'but their ${method.originalName} methods have a parameter at '
129-
'position ${i + 1} with an unrelated type',
130-
);
131-
return;
132-
}
133-
134-
logger.info(
135-
'Set the parameter of '
136-
'${node.originalName}.${method.originalName} at position ${i + 1} to '
137-
'be covariant',
138-
);
139-
method.params.elementAt(i).isCovariant = true;
140-
}
141-
}
142-
14395
void _fixMethodVariance(ObjCInterface node) {
14496
for (final method in node.methods) {
14597
if (method.isClassMethod) continue;
14698
final (superType, superMethod) = _findNearestWithMethod(node, method);
14799
if (superType != null && superMethod != null) {
148100
_fixContravariantReturns(node, method, superType, superMethod);
149-
_fixCoavariantArgs(node, method, superType, superMethod);
150101
}
151102
}
152103
}

0 commit comments

Comments
 (0)