@@ -4280,48 +4280,50 @@ void TypeChecker::checkParameterList(ParameterList *params,
4280
4280
}
4281
4281
4282
4282
// Opaque types cannot occur in parameter position.
4283
- Type interfaceType = param->getInterfaceType ();
4284
- if (interfaceType->hasTypeParameter ()) {
4285
- interfaceType.findIf ([&](Type type) {
4286
- if (auto fnType = type->getAs <FunctionType>()) {
4287
- for (auto innerParam : fnType->getParams ()) {
4288
- auto paramType = innerParam.getPlainType ();
4289
- if (!paramType->hasTypeParameter ())
4290
- continue ;
4291
-
4292
- bool hadError = paramType.findIf ([&](Type innerType) {
4293
- auto genericParam = innerType->getAs <GenericTypeParamType>();
4294
- if (!genericParam)
4295
- return false ;
4296
-
4297
- auto genericParamDecl = genericParam->getOpaqueDecl ();
4298
- if (!genericParamDecl)
4299
- return false ;
4300
-
4301
- param->diagnose (
4302
- diag::opaque_type_in_parameter, true , interfaceType);
4303
- return true ;
4304
- });
4283
+ if (!isa<ClosureExpr>(owner)) {
4284
+ Type interfaceType = param->getInterfaceType ();
4285
+ if (interfaceType->hasTypeParameter ()) {
4286
+ interfaceType.findIf ([&](Type type) {
4287
+ if (auto fnType = type->getAs <FunctionType>()) {
4288
+ for (auto innerParam : fnType->getParams ()) {
4289
+ auto paramType = innerParam.getPlainType ();
4290
+ if (!paramType->hasTypeParameter ())
4291
+ continue ;
4292
+
4293
+ bool hadError = paramType.findIf ([&](Type innerType) {
4294
+ auto genericParam = innerType->getAs <GenericTypeParamType>();
4295
+ if (!genericParam)
4296
+ return false ;
4297
+
4298
+ auto genericParamDecl = genericParam->getOpaqueDecl ();
4299
+ if (!genericParamDecl)
4300
+ return false ;
4301
+
4302
+ param->diagnose (
4303
+ diag::opaque_type_in_parameter, true , interfaceType);
4304
+ return true ;
4305
+ });
4306
+
4307
+ if (hadError)
4308
+ return true ;
4309
+ }
4305
4310
4306
- if (hadError)
4307
- return true ;
4311
+ return false ;
4308
4312
}
4309
4313
4310
4314
return false ;
4311
- }
4312
-
4313
- return false ;
4314
- });
4315
+ });
4316
+ }
4315
4317
}
4316
4318
4317
4319
if (param->hasAttachedPropertyWrapper ())
4318
4320
(void ) param->getPropertyWrapperInitializerInfo ();
4319
4321
4320
- auto *SF = param->getDeclContext ()->getParentSourceFile ();
4321
4322
if (!param->isInvalid ()) {
4323
+ auto *SF = owner->getParentSourceFile ();
4322
4324
param->visitAuxiliaryDecls ([&](VarDecl *auxiliaryDecl) {
4323
4325
if (!isa<ParamDecl>(auxiliaryDecl))
4324
- DeclChecker (param ->getASTContext (), SF).visitBoundVariable (auxiliaryDecl);
4326
+ DeclChecker (SF ->getASTContext (), SF).visitBoundVariable (auxiliaryDecl);
4325
4327
});
4326
4328
}
4327
4329
0 commit comments