Skip to content

Commit c684ad2

Browse files
committed
AST: Fix for DeclContext::createSelf() with static members and inouts
1 parent 680688c commit c684ad2

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/AST/Decl.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,21 +3687,28 @@ ParamDecl *ParamDecl::createSelf(SourceLoc loc, DeclContext *DC,
36873687
bool isStaticMethod, bool isInOut) {
36883688
ASTContext &C = DC->getASTContext();
36893689
auto selfType = DC->getSelfTypeInContext();
3690+
auto selfInterfaceType = DC->getSelfInterfaceType();
3691+
3692+
assert(!!selfType == !!selfInterfaceType);
36903693

36913694
// If we have a selfType (i.e. we're not in the parser before we know such
36923695
// things, configure it.
3693-
if (selfType) {
3694-
if (isStaticMethod)
3696+
if (selfType && selfInterfaceType) {
3697+
if (isStaticMethod) {
36953698
selfType = MetatypeType::get(selfType);
3699+
selfInterfaceType = MetatypeType::get(selfInterfaceType);
3700+
}
36963701

3697-
if (isInOut)
3702+
if (isInOut) {
36983703
selfType = InOutType::get(selfType);
3704+
selfInterfaceType = InOutType::get(selfInterfaceType);
3705+
}
36993706
}
3700-
3707+
37013708
auto *selfDecl = new (C) ParamDecl(/*IsLet*/!isInOut, SourceLoc(),SourceLoc(),
37023709
Identifier(), loc, C.Id_self, selfType,DC);
37033710
selfDecl->setImplicit();
3704-
selfDecl->setInterfaceType(DC->getSelfInterfaceType());
3711+
selfDecl->setInterfaceType(selfInterfaceType);
37053712
return selfDecl;
37063713
}
37073714

0 commit comments

Comments
 (0)