@@ -82,8 +82,10 @@ ${superMember} is a ${_memberKind(superMember)}
8282 ? ownMember.isCovariantByDeclaration
8383 : ownMember
8484 .function! .positionalParameters[0 ].isCovariantByDeclaration;
85- if (! _isValidParameterOverride (
86- isCovariantByDeclaration, ownType, superType)) {
85+ if (! _isValidParameterOverride (ownType, superType,
86+ isCovariantByDeclaration: isCovariantByDeclaration,
87+ isSuperNoSuchMethodForwarder: superMember is Procedure &&
88+ superMember.isNoSuchMethodForwarder)) {
8789 if (isCovariantByDeclaration) {
8890 return failures.reportInvalidOverride (ownMember, superMember, '''
8991${ownType } is neither a subtype nor supertype of ${superType }
@@ -203,9 +205,10 @@ ${ownType} is not a subtype of ${superType}
203205 final VariableDeclaration superParameter =
204206 superFunction.positionalParameters[i];
205207 if (! _isValidParameterOverride (
206- ownParameter.isCovariantByDeclaration,
207208 ownSubstitution.substituteType (ownParameter.type),
208- superSubstitution.substituteType (superParameter.type))) {
209+ superSubstitution.substituteType (superParameter.type),
210+ isCovariantByDeclaration: ownParameter.isCovariantByDeclaration,
211+ isSuperNoSuchMethodForwarder: superMember.isNoSuchMethodForwarder)) {
209212 return '''
210213type of parameter ${ownParameter .name } is incompatible
211214override declares ${ownParameter .type }
@@ -232,9 +235,10 @@ super method declares ${superParameter.type}
232235 }
233236
234237 if (! _isValidParameterOverride (
235- ownParameter.isCovariantByDeclaration,
236238 ownSubstitution.substituteType (ownParameter.type),
237- superSubstitution.substituteType (superParameter.type))) {
239+ superSubstitution.substituteType (superParameter.type),
240+ isCovariantByDeclaration: ownParameter.isCovariantByDeclaration,
241+ isSuperNoSuchMethodForwarder: superMember.isNoSuchMethodForwarder)) {
238242 return '''
239243type of parameter ${ownParameter .name } is incompatible
240244override declares ${ownParameter .type }
@@ -249,14 +253,27 @@ super method declares ${superParameter.type}
249253 /// Checks whether parameter with [ownParameterType] type is a valid override
250254 /// for parameter with [superParameterType] type taking into account its
251255 /// covariance and applying type parameter [substitution] if necessary.
252- bool _isValidParameterOverride (bool isCovariantByDeclaration,
253- DartType ownParameterType, DartType superParameterType) {
256+ bool _isValidParameterOverride (
257+ DartType ownParameterType, DartType superParameterType,
258+ {required bool isCovariantByDeclaration,
259+ required bool isSuperNoSuchMethodForwarder}) {
254260 if (_isSubtypeOf (superParameterType, ownParameterType)) {
255261 return true ;
256262 } else if (isCovariantByDeclaration &&
257263 _isSubtypeOf (ownParameterType, superParameterType)) {
258264 return true ;
259265 } else {
266+ // In noSuchMethod forwarders some types of parameters are adjusted to be
267+ // nullable. This is a workaround for the backends, and the corresponding
268+ // type mismatch should be ignored by the verifier.
269+ if (isSuperNoSuchMethodForwarder) {
270+ return _isValidParameterOverride (
271+ ownParameterType.withDeclaredNullability (Nullability .nullable),
272+ superParameterType,
273+ isCovariantByDeclaration: isCovariantByDeclaration,
274+ isSuperNoSuchMethodForwarder: false );
275+ }
276+
260277 return false ;
261278 }
262279 }
0 commit comments