@@ -4506,22 +4506,27 @@ TypeResolver::resolveIsolatedTypeRepr(IsolatedTypeRepr *repr,
4506
4506
return ErrorType::get (getASTContext ());
4507
4507
}
4508
4508
4509
+ // Keep the `type` to be returned, while we unwrap and inspect the inner
4510
+ // type for whether it can be isolated on.
4509
4511
Type type = resolveType (repr->getBase (), options);
4512
+ Type unwrappedType = type;
4510
4513
4511
- if (auto ty = dyn_cast<DynamicSelfType>(type)) {
4512
- type = ty->getSelfType ();
4514
+ // Optional actor types are fine - `nil` represents `nonisolated`.
4515
+ auto allowOptional = getASTContext ().LangOpts
4516
+ .hasFeature (Feature::OptionalIsolatedParameters);
4517
+ if (allowOptional) {
4518
+ if (auto wrappedOptionalType = unwrappedType->getOptionalObjectType ()) {
4519
+ unwrappedType = wrappedOptionalType;
4520
+ }
4521
+ }
4522
+ if (auto dynamicSelfType = dyn_cast<DynamicSelfType>(unwrappedType)) {
4523
+ unwrappedType = dynamicSelfType->getSelfType ();
4513
4524
}
4514
4525
4515
4526
// isolated parameters must be of actor type
4516
- if (!type->hasTypeParameter () && !type->isAnyActorType () && !type->hasError ()) {
4517
- // Optional actor types are fine - `nil` represents `nonisolated`.
4518
- auto wrapped = type->getOptionalObjectType ();
4519
- auto allowOptional = getASTContext ().LangOpts
4520
- .hasFeature (Feature::OptionalIsolatedParameters);
4521
- if (allowOptional && wrapped && wrapped->isAnyActorType ()) {
4522
- return type;
4523
- }
4524
-
4527
+ if (!unwrappedType->isTypeParameter () &&
4528
+ !unwrappedType->isAnyActorType () &&
4529
+ !unwrappedType->hasError ()) {
4525
4530
diagnoseInvalid (
4526
4531
repr, repr->getSpecifierLoc (), diag::isolated_parameter_not_actor, type);
4527
4532
return ErrorType::get (type);
0 commit comments