[Scope map] A local property name is in scope within its own accessors.

While the use of a local property from within its own accessors is a
bit dubious, Swift 3 only warned on it, so model the existing lookup
behavior in the scope map.
This commit is contained in:
Doug Gregor
2016-09-14 09:16:23 -07:00
parent 40445be66a
commit ac93c52c96
6 changed files with 62 additions and 63 deletions

View File

@@ -317,7 +317,7 @@ void swift::convertStoredVarInProtocolToComputed(VarDecl *VD, TypeChecker &TC) {
auto *Get = createGetterPrototype(VD, TC);
// Okay, we have both the getter and setter. Set them in VD.
VD->makeComputed(VD->getLoc(), Get, nullptr, nullptr, VD->getLoc());
VD->makeComputed(SourceLoc(), Get, nullptr, nullptr, SourceLoc());
// We've added some members to our containing class, add them to the members
// list.
@@ -983,7 +983,7 @@ static void convertNSManagedStoredVarToComputed(VarDecl *VD, TypeChecker &TC) {
if (VD->hasAccessorFunctions()) return;
// Okay, we have both the getter and setter. Set them in VD.
VD->makeComputed(VD->getLoc(), Get, Set, nullptr, VD->getLoc());
VD->makeComputed(SourceLoc(), Get, Set, nullptr, SourceLoc());
TC.validateDecl(Get);
TC.validateDecl(Set);
@@ -1736,7 +1736,7 @@ void swift::maybeAddAccessorsToVariable(VarDecl *var, TypeChecker &TC) {
setter->setAccessibility(var->getFormalAccess());
}
var->makeComputed(var->getLoc(), getter, setter, nullptr, var->getLoc());
var->makeComputed(SourceLoc(), getter, setter, nullptr, SourceLoc());
// Save the conformance and 'value' decl for later type checking.
behavior->Conformance = conformance;
@@ -1841,8 +1841,7 @@ void swift::maybeAddAccessorsToVariable(VarDecl *var, TypeChecker &TC) {
ParamDecl *newValueParam = nullptr;
auto *setter = createSetterPrototype(var, newValueParam, TC);
var->makeComputed(var->getLoc(), getter, setter, nullptr,
var->getLoc());
var->makeComputed(SourceLoc(), getter, setter, nullptr, SourceLoc());
var->setIsBeingTypeChecked(false);
TC.validateDecl(getter);