Skip to content

Commit 89c9e03

Browse files
committed
[Sema] Revise #15280 in response to feedback (2)
Use VarDecl::isSelfParameter to check whether the base is 'self'.
1 parent 4b0cbc0 commit 89c9e03

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,8 @@ getImplicitMemberReferenceAccessSemantics(Expr *base, VarDecl *member,
250250
// Check whether this is a member access on 'self'.
251251
bool isAccessOnSelf = false;
252252
if (auto *baseDRE = dyn_cast<DeclRefExpr>(base->getValueProvidingExpr()))
253-
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(DC))
254-
if (auto *selfDecl = AFD->getImplicitSelfDecl())
255-
if (baseDRE->getDecl() == selfDecl)
256-
isAccessOnSelf = true;
253+
if (auto *baseVar = dyn_cast<VarDecl>(baseDRE->getDecl()))
254+
isAccessOnSelf = baseVar->isSelfParameter();
257255

258256
// If the value is always directly accessed from this context, do it.
259257
return member->getAccessSemanticsFromContext(DC, isAccessOnSelf);

test/SILGen/properties_swift4.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// RUN: %target-swift-frontend -swift-version 4 -module-name properties -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -swift-version 4 -module-name properties -Xllvm -sil-full-demangle -parse-as-library -emit-silgen %s | %FileCheck %s
33

44
var zero: Int = 0
55

test/SILGen/properties_swift5.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// RUN: %target-swift-frontend -swift-version 5 -module-name properties -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -swift-version 5 -module-name properties -Xllvm -sil-full-demangle -parse-as-library -emit-silgen %s | %FileCheck %s
33

44
var zero: Int = 0
55

0 commit comments

Comments
 (0)