Skip to content

Commit 6665e71

Browse files
committed
[AST] Use getExtendedProtocolDecl() to check for protocol extension and use getDeclaredInterfaceType() instead of getSelfTypeInContext() - both are cheaper
1 parent 6ca121d commit 6665e71

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/AST/DeclContext.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,21 +1036,18 @@ DeclContextKind DeclContext::getContextKind() const {
10361036
}
10371037

10381038
bool DeclContext::hasValueSemantics() const {
1039-
if (auto contextTy = getSelfTypeInContext()) {
1040-
return !contextTy->hasReferenceSemantics();
1041-
}
1039+
if (getExtendedProtocolDecl())
1040+
return !isClassConstrainedProtocolExtension();
1041+
return !getDeclaredInterfaceType()->hasReferenceSemantics();
10421042

10431043
return false;
10441044
}
10451045

10461046
bool DeclContext::isClassConstrainedProtocolExtension() const {
1047-
if (auto ED = dyn_cast<ExtensionDecl>(this)) {
1048-
if (ED->getExtendedType()->isExistentialType()) {
1049-
return ED->getGenericSignature()->requiresClass(
1050-
ED->getSelfInterfaceType());
1051-
}
1047+
if (getExtendedProtocolDecl()) {
1048+
auto ED = cast<ExtensionDecl>(this);
1049+
return ED->getGenericSignature()->requiresClass(ED->getSelfInterfaceType());
10521050
}
1053-
10541051
return false;
10551052
}
10561053

0 commit comments

Comments
 (0)