@@ -1032,7 +1032,12 @@ static std::string getDeclNameFromContext(DeclContext *dc,
1032
1032
}
1033
1033
}
1034
1034
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) {
1036
1041
auto dc = resolution.getDeclContext ();
1037
1042
ASTContext &ctx = dc->getASTContext ();
1038
1043
DeclContext *nominalDC = nullptr ;
@@ -1044,24 +1049,13 @@ static Type isSE0068(TypeResolution resolution, TypeResolutionOptions options) {
1044
1049
bool insideClass = nominalDC->getSelfClassDecl () != nullptr ;
1045
1050
AbstractFunctionDecl *methodDecl = dc->getInnermostMethodContext ();
1046
1051
bool declaringMethod = methodDecl &&
1047
- methodDecl->getDeclContext () == dc->getParentForLookup ();
1052
+ methodDecl->getDeclContext () == dc->getParentForLookup ();
1048
1053
bool isMutablePropertyOrSubscriptOfClass = insideClass &&
1049
1054
(options.is (TypeResolverContext::PatternBindingDecl) ||
1050
1055
options.is (TypeResolverContext::FunctionResult));
1051
1056
bool isTypeAliasInClass = insideClass &&
1052
1057
options.is (TypeResolverContext::TypeAliasDecl);
1053
1058
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
-
1065
1059
if (((!insideClass || !declaringMethod) &&
1066
1060
!isMutablePropertyOrSubscriptOfClass && !isTypeAliasInClass &&
1067
1061
!options.is (TypeResolverContext::GenericRequirement)) ||
@@ -1370,7 +1364,7 @@ resolveTopLevelIdentTypeComponent(TypeResolution resolution,
1370
1364
return ErrorType::get (ctx);
1371
1365
1372
1366
if (id == ctx.Id_Self )
1373
- if (auto SelfType = isSE0068 (resolution, options))
1367
+ if (auto SelfType = SelfAllowedBySE0068 (resolution, options))
1374
1368
return SelfType;
1375
1369
1376
1370
return diagnoseUnknownType (resolution, nullptr , SourceRange (), comp,
0 commit comments