Skip to content

Commit 98a4f94

Browse files
authored
Merge pull request swiftlang#10516 from slavapestov/code-review-is-good
Two really tiny fixes from code review feedback
2 parents 4b79360 + 7bbc2ae commit 98a4f94

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,15 +2318,19 @@ void PrintAST::visitPatternBindingDecl(PatternBindingDecl *decl) {
23182318

23192319
if (anyVar)
23202320
printDocumentationComment(anyVar);
2321-
if (decl->isStatic())
2322-
printStaticKeyword(decl->getCorrectStaticSpelling());
23232321

23242322
// FIXME: PatternBindingDecls don't have attributes themselves, so just assume
23252323
// the variables all have the same attributes. This isn't exactly true
23262324
// after type-checking, but it's close enough for now.
23272325
if (anyVar) {
23282326
printAttributes(anyVar);
23292327
printAccessibility(anyVar);
2328+
}
2329+
2330+
if (decl->isStatic())
2331+
printStaticKeyword(decl->getCorrectStaticSpelling());
2332+
2333+
if (anyVar) {
23302334
Printer << (anyVar->isSettable(anyVar->getDeclContext()) ? "var " : "let ");
23312335
} else {
23322336
Printer << "let ";

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,8 +2560,8 @@ static void inferDynamic(ASTContext &ctx, ValueDecl *D) {
25602560
if (auto VD = dyn_cast<VarDecl>(D)) {
25612561
auto staticSpelling = VD->getParentPatternBinding()->getStaticSpelling();
25622562

2563-
// The presence of 'static' bocks the inference of 'dynamic'.
2564-
if (VD->isStatic() && staticSpelling == StaticSpellingKind::KeywordStatic)
2563+
// The presence of 'static' blocks the inference of 'dynamic'.
2564+
if (staticSpelling == StaticSpellingKind::KeywordStatic)
25652565
return;
25662566

25672567
if (VD->isLet() && !isNSManaged)
@@ -2577,7 +2577,7 @@ static void inferDynamic(ASTContext &ctx, ValueDecl *D) {
25772577
auto staticSpelling = FD->getStaticSpelling();
25782578

25792579
// The presence of 'static' bocks the inference of 'dynamic'.
2580-
if (FD->isStatic() && staticSpelling == StaticSpellingKind::KeywordStatic)
2580+
if (staticSpelling == StaticSpellingKind::KeywordStatic)
25812581
return;
25822582
}
25832583

test/attr/attr_dynamic_infer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extension FinalTests {
7878
set { }
7979
}
8080

81-
// CHECK: static @objc var x
81+
// CHECK: @objc static var x
8282
static var x: Int = 0
8383

8484
// CHECK: @objc static func bar

0 commit comments

Comments
 (0)