Skip to content

Commit 7ae9683

Browse files
committed
Merge pull request #2772 from CodaFi/inner-turmoil
2 parents 778a4ee + 586aefd commit 7ae9683

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4600,11 +4600,18 @@ ConstructorDecl::getDelegatingOrChainedInitKind(DiagnosticEngine *diags,
46004600
return false;
46014601
}
46024602

4603+
bool walkToDeclPre(class Decl *D) override {
4604+
// Don't walk into further nominal decls.
4605+
if (isa<NominalTypeDecl>(D))
4606+
return false;
4607+
return true;
4608+
}
4609+
46034610
std::pair<bool, Expr*> walkToExprPre(Expr *E) override {
46044611
// Don't walk into closures.
46054612
if (isa<ClosureExpr>(E))
46064613
return { false, E };
4607-
4614+
46084615
// Look for calls of a constructor on self or super.
46094616
auto apply = dyn_cast<ApplyExpr>(E);
46104617
if (!apply)
@@ -4676,7 +4683,7 @@ ConstructorDecl::getDelegatingOrChainedInitKind(DiagnosticEngine *diags,
46764683
if (Kind == BodyInitKind::None && getAttrs().hasAttribute<ConvenienceAttr>())
46774684
Kind = BodyInitKind::Delegating;
46784685

4679-
// If wes till don't know, check whether we have a class with a superclass: it
4686+
// If we still don't know, check whether we have a class with a superclass: it
46804687
// gets an implicit chained initializer.
46814688
if (Kind == BodyInitKind::None) {
46824689
if (auto classDecl = getDeclContext()->getAsClassOrClassExtensionContext()) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %target-parse-verify-swift
2+
3+
class A {
4+
init() {}
5+
}
6+
7+
class B {
8+
init() {}
9+
10+
convenience init(x: ()) {
11+
class C: A {
12+
override init() { // No error
13+
super.init()
14+
}
15+
}
16+
17+
class D: A {
18+
convenience init(x: ()) {
19+
class DI : A {
20+
override init() { // No error
21+
super.init()
22+
}
23+
}
24+
25+
self.init()
26+
}
27+
28+
override init() { // No error
29+
class DI : A {
30+
override init() { // No error
31+
super.init()
32+
}
33+
}
34+
super.init()
35+
}
36+
}
37+
38+
struct E {
39+
init() {} // No error
40+
}
41+
42+
self.init()
43+
}
44+
}
45+

0 commit comments

Comments
 (0)