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 @@ -3508,12 +3508,14 @@ void PrintAST::visitPatternBindingDecl(PatternBindingDecl *decl) {
35083508 if (decl->isStatic ())
35093509 printStaticKeyword (decl->getCorrectStaticSpelling ());
35103510
3511+ bool printAsVar = false ;
35113512 if (anyVar) {
3512- Printer << (anyVar->isSettable (anyVar->getDeclContext ()) ? " var " : " let " );
3513- } else {
3514- Printer << " let " ;
3513+ printAsVar = (anyVar->isSettable (anyVar->getDeclContext ()) ||
3514+ isInObjCImpl (anyVar));
35153515 }
35163516
3517+ Printer << (printAsVar ? " var " : " let " );
3518+
35173519 bool isFirst = true ;
35183520 for (auto idx : range (decl->getNumPatternEntries ())) {
35193521 auto *pattern = decl->getPattern (idx);
@@ -3958,9 +3960,9 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
39583960 // Map all non-let specifiers to 'var'. This is not correct, but
39593961 // SourceKit relies on this for info about parameter decls.
39603962
3961- Printer. printIntroducerKeyword (
3962- introducer == VarDecl::Introducer::Let ? " let " : " var " ,
3963- Options, " " );
3963+ bool printAsVar = (introducer != VarDecl::Introducer::Let ||
3964+ isInObjCImpl (decl));
3965+ Printer. printIntroducerKeyword (printAsVar ? " var " : " let " , Options, " " );
39643966 }
39653967 printContextIfNeeded (decl);
39663968 recordDeclLoc (decl,
Original file line number Diff line number Diff line change 44
55- (nonnull instancetype )init ;
66
7+ @property (readonly ) int letProperty1;
78@property (assign ) int implProperty;
89
910- (void )mainMethod : (int )param ;
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ import Foundation
4242 didSet { print ( implProperty) }
4343 }
4444
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+
4551 // CHECK-DAG: final public var implProperty2: ObjectiveC.NSObject? { get set }
4652 public final var implProperty2 : NSObject ?
4753
You can’t perform that action at this time.
0 commit comments