File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -4914,7 +4914,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4914
4914
return cast<VarDecl>(accessor)->getTypeLoc ();
4915
4915
}
4916
4916
4917
- static bool functionHasImplicitlyUnwrappedResult (FuncDecl *FD) {
4917
+ static bool functionHasImplicitlyUnwrappedResult (AbstractFunctionDecl *AFD) {
4918
+ if (auto *CD = dyn_cast<ConstructorDecl>(AFD)) {
4919
+ return CD->getFailability () == OTK_ImplicitlyUnwrappedOptional;
4920
+ }
4921
+
4922
+ auto *FD = cast<FuncDecl>(AFD);
4918
4923
if (FD->isAccessor () && !FD->isGetter ())
4919
4924
return false ;
4920
4925
@@ -7271,6 +7276,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
7271
7276
7272
7277
inferDynamic (TC.Context , CD);
7273
7278
7279
+ if (functionHasImplicitlyUnwrappedResult (CD)) {
7280
+ auto &C = CD->getASTContext ();
7281
+ CD->getAttrs ().add (
7282
+ new (C) ImplicitlyUnwrappedOptionalAttr (/* implicit= */ true ));
7283
+ }
7284
+
7274
7285
TC.checkDeclAttributes (CD);
7275
7286
}
7276
7287
You can’t perform that action at this time.
0 commit comments