File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Inputs/objc_implementation Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -3506,12 +3506,14 @@ void PrintAST::visitPatternBindingDecl(PatternBindingDecl *decl) {
3506
3506
if (decl->isStatic ())
3507
3507
printStaticKeyword (decl->getCorrectStaticSpelling ());
3508
3508
3509
+ bool printAsVar = false ;
3509
3510
if (anyVar) {
3510
- Printer << (anyVar->isSettable (anyVar->getDeclContext ()) ? " var " : " let " );
3511
- } else {
3512
- Printer << " let " ;
3511
+ printAsVar = (anyVar->isSettable (anyVar->getDeclContext ()) ||
3512
+ isInObjCImpl (anyVar));
3513
3513
}
3514
3514
3515
+ Printer << (printAsVar ? " var " : " let " );
3516
+
3515
3517
bool isFirst = true ;
3516
3518
for (auto idx : range (decl->getNumPatternEntries ())) {
3517
3519
auto *pattern = decl->getPattern (idx);
@@ -3949,9 +3951,9 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
3949
3951
// Map all non-let specifiers to 'var'. This is not correct, but
3950
3952
// SourceKit relies on this for info about parameter decls.
3951
3953
3952
- Printer. printIntroducerKeyword (
3953
- decl-> getIntroducer () == VarDecl::Introducer::Let ? " let " : " var " ,
3954
- Options, " " );
3954
+ bool printAsVar = (decl-> getIntroducer () != VarDecl::Introducer::Let ||
3955
+ isInObjCImpl (decl));
3956
+ Printer. printIntroducerKeyword (printAsVar ? " var " : " let " , Options, " " );
3955
3957
}
3956
3958
printContextIfNeeded (decl);
3957
3959
recordDeclLoc (decl,
Original file line number Diff line number Diff line change 4
4
5
5
- (nonnull instancetype )init ;
6
6
7
+ @property (readonly ) int letProperty1;
7
8
@property (assign ) int implProperty;
8
9
9
10
- (void )mainMethod : (int )param ;
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ import Foundation
42
42
didSet { print ( implProperty) }
43
43
}
44
44
45
+ // CHECK-NOT: var letProperty1:
46
+ @objc public let letProperty1 : Int32
47
+
48
+ // CHECK-DAG: @nonobjc public var letProperty2: Swift.Int32 { get }
49
+ @nonobjc public let letProperty2 : Int32
50
+
45
51
// CHECK-DAG: final public var implProperty2: ObjectiveC.NSObject? { get set }
46
52
public final var implProperty2 : NSObject ?
47
53
You can’t perform that action at this time.
0 commit comments