Skip to content

Commit 6df3ac2

Browse files
committed
IUO: Look through SpecifierTypeRepr when adding IUO attributes.
1 parent 406a025 commit 6df3ac2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,15 @@ static bool validateParameterType(ParamDecl *decl, DeclContext *DC,
729729
elementOptions, &resolver);
730730
}
731731

732+
auto *TR = TL.getTypeRepr();
733+
if (auto *STR = dyn_cast_or_null<SpecifierTypeRepr>(TR))
734+
TR = STR->getBase();
735+
732736
// If this is declared with '!' indicating that it is an Optional
733737
// that we should implicitly unwrap if doing so is required to type
734738
// check, then add an attribute to the decl.
735-
if (elementOptions.contains(TypeResolutionFlags::AllowIUO)
736-
&& TL.getTypeRepr() && TL.getTypeRepr()->getKind() ==
737-
TypeReprKind::ImplicitlyUnwrappedOptional) {
739+
if (elementOptions.contains(TypeResolutionFlags::AllowIUO) && TR &&
740+
TR->getKind() == TypeReprKind::ImplicitlyUnwrappedOptional) {
738741
auto &C = DC->getASTContext();
739742
decl->getAttrs().add(
740743
new (C) ImplicitlyUnwrappedOptionalAttr(/* implicit= */ true));

0 commit comments

Comments
 (0)