Skip to content

Commit 7ae55d3

Browse files
committed
Tidy up comments and final testing.
1 parent afba3d4 commit 7ae55d3

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,12 @@ static std::string getDeclNameFromContext(DeclContext *dc,
10321032
}
10331033
}
10341034

1035-
static Type isSE0068(TypeResolution resolution, TypeResolutionOptions options) {
1035+
//
1036+
// SE-0068 is "Expanding Swift Self to class members and value types"
1037+
// https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md
1038+
//
1039+
static Type SelfAllowedBySE0068(TypeResolution resolution,
1040+
TypeResolutionOptions options) {
10361041
auto dc = resolution.getDeclContext();
10371042
ASTContext &ctx = dc->getASTContext();
10381043
DeclContext *nominalDC = nullptr;
@@ -1044,24 +1049,13 @@ static Type isSE0068(TypeResolution resolution, TypeResolutionOptions options) {
10441049
bool insideClass = nominalDC->getSelfClassDecl() != nullptr;
10451050
AbstractFunctionDecl *methodDecl = dc->getInnermostMethodContext();
10461051
bool declaringMethod = methodDecl &&
1047-
methodDecl->getDeclContext() == dc->getParentForLookup();
1052+
methodDecl->getDeclContext() == dc->getParentForLookup();
10481053
bool isMutablePropertyOrSubscriptOfClass = insideClass &&
10491054
(options.is(TypeResolverContext::PatternBindingDecl) ||
10501055
options.is(TypeResolverContext::FunctionResult));
10511056
bool isTypeAliasInClass = insideClass &&
10521057
options.is(TypeResolverContext::TypeAliasDecl);
10531058

1054-
// printf("%d\n", options.getBaseContext());
1055-
1056-
// Causes: Assertion failed: (hasSelfMetadataParam() && "This method can only be called if the " "SILFunction has a self-metadata parameter"), function getSelfMetadataArgument, file /Volumes/Elements/swift-self/swift/include/swift/SIL/SILFunction.h, line 955.
1057-
1058-
// if (isMutablePropertyOrSubscriptOfClass) {
1059-
// if (auto prop = dyn_cast_or_null<ValueDecl>
1060-
// (dc->getInnermostDeclarationDeclContext()))
1061-
// if (!prop->isSettable(dc))
1062-
// isMutablePropertyOrSubscriptOfClass = false;
1063-
// }
1064-
10651059
if (((!insideClass || !declaringMethod) &&
10661060
!isMutablePropertyOrSubscriptOfClass && !isTypeAliasInClass &&
10671061
!options.is(TypeResolverContext::GenericRequirement)) ||
@@ -1370,7 +1364,7 @@ resolveTopLevelIdentTypeComponent(TypeResolution resolution,
13701364
return ErrorType::get(ctx);
13711365

13721366
if (id == ctx.Id_Self)
1373-
if (auto SelfType = isSE0068(resolution, options))
1367+
if (auto SelfType = SelfAllowedBySE0068(resolution, options))
13741368
return SelfType;
13751369

13761370
return diagnoseUnknownType(resolution, nullptr, SourceRange(), comp,

0 commit comments

Comments
 (0)