Skip to content

Commit b36f772

Browse files
committed
[CSDiag] Check if TypeExpr has type and a nominal decl
1 parent c1c4ca5 commit b36f772

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,19 +3353,30 @@ class ArgumentMatcher : public MatchCallArgumentListener {
33533353
}
33543354

33553355
bool isPropertyWrapperImplicitInit() {
3356-
if (auto TE = dyn_cast<TypeExpr>(FnExpr)) {
3357-
if (TE->getInstanceType()
3358-
->getAnyNominal()
3359-
->getAttrs()
3360-
.hasAttribute<PropertyWrapperAttr>()) {
3361-
if (auto parent = CandidateInfo.CS.getParentExpr(FnExpr)) {
3362-
if (auto CE = dyn_cast<CallExpr>(parent)) {
3363-
return CE->isImplicit();
3364-
}
3365-
}
3366-
}
3367-
}
3368-
return false;
3356+
auto TE = dyn_cast<TypeExpr>(FnExpr);
3357+
if (!TE)
3358+
return false;
3359+
3360+
auto instanceTy = TE->getInstanceType();
3361+
if (!instanceTy)
3362+
return false;
3363+
3364+
auto nominalDecl = instanceTy->getAnyNominal();
3365+
if (!nominalDecl)
3366+
return false;
3367+
3368+
if (!nominalDecl->getAttrs().hasAttribute<PropertyWrapperAttr>())
3369+
return false;
3370+
3371+
auto parent = CandidateInfo.CS.getParentExpr(FnExpr);
3372+
if (!parent)
3373+
return false;
3374+
3375+
auto CE = dyn_cast<CallExpr>(parent);
3376+
if (!CE)
3377+
return false;
3378+
3379+
return CE->isImplicit();
33693380
}
33703381

33713382
bool missingLabel(unsigned paramIdx) override {

0 commit comments

Comments
 (0)