diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index a17af549f77..bebb032b14b 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -1187,14 +1187,19 @@ ERROR(access_control_setter_more,none, "%select{variable|property|subscript}1 cannot have " "%select{%error|a fileprivate|an internal|a public|an open}2 setter", (AccessLevel, unsigned, AccessLevel)) +WARNING(access_control_setter_redundant,none, + "'%select{private|fileprivate|internal|public|open}0(set)' modifier is " + "redundant for %select{a private|a fileprivate|an internal|a public|an open}2 " + "%1", + (AccessLevel, DescriptiveDeclKind, AccessLevel)) WARNING(access_control_ext_member_more,none, "declaring %select{%error|a fileprivate|an internal|a public|open}0 %1 in " "%select{a private|a fileprivate|an internal|a public|%error}2 extension", (AccessLevel, DescriptiveDeclKind, AccessLevel)) WARNING(access_control_ext_member_redundant,none, "'%select{%error|fileprivate|internal|public|%error}0' modifier is redundant " - "for %1 declared in %select{%error|a fileprivate|an internal|a public|%error}2 " - "extension", + "for %1 declared in %select{a private (equivalent to fileprivate)|a fileprivate" + "|an internal|a public|%error}2 extension", (AccessLevel, DescriptiveDeclKind, AccessLevel)) ERROR(access_control_ext_requirement_member_more,none, "cannot declare %select{%error|a fileprivate|an internal|a public|an open}0 %1 " diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 96463386b08..f6cd85c0c37 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -3952,7 +3952,7 @@ void swift::performStmtDiagnostics(TypeChecker &TC, const Stmt *S) { void swift::fixItAccess(InFlightDiagnostic &diag, ValueDecl *VD, AccessLevel desiredAccess, bool isForSetter, - bool shouldNotReplace) { + bool shouldUseDefaultAccess) { StringRef fixItString; switch (desiredAccess) { case AccessLevel::Private: fixItString = "private "; break; @@ -3998,7 +3998,7 @@ void swift::fixItAccess(InFlightDiagnostic &diag, ValueDecl *VD, // this function is sometimes called to make access narrower, so assuming // that a broader scope is acceptable breaks some diagnostics. if (attr->getAccess() != desiredAccess) { - if (shouldNotReplace) { + if (shouldUseDefaultAccess) { // Remove the attribute if replacement is not preferred. diag.fixItRemove(attr->getRange()); } else { diff --git a/lib/Sema/MiscDiagnostics.h b/lib/Sema/MiscDiagnostics.h index 5864a3c9eb4..e0d53b6580f 100644 --- a/lib/Sema/MiscDiagnostics.h +++ b/lib/Sema/MiscDiagnostics.h @@ -55,7 +55,7 @@ void fixItAccess(InFlightDiagnostic &diag, ValueDecl *VD, AccessLevel desiredAccess, bool isForSetter = false, - bool shouldNotReplace = false); + bool shouldUseDefaultAccess = false); /// Emit fix-its to correct the argument labels in \p expr, which is the /// argument tuple or single argument of a call. diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 2bfeb01f509..33e8d00230a 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -1459,13 +1459,6 @@ static bool hasThrowingFunctionParameter(CanType type) { return false; } -static inline bool isRedundantAttrInExtension(AccessLevel access, - AccessControlAttr *extAttr) { - return access == extAttr->getAccess() && - access != AccessLevel::Private && - access != AccessLevel::Open; -} - void AttributeChecker::visitRethrowsAttr(RethrowsAttr *attr) { // 'rethrows' only applies to functions that take throwing functions // as parameters. @@ -1519,22 +1512,17 @@ void AttributeChecker::visitAccessControlAttr(AccessControlAttr *attr) { if (auto extAttr = extension->getAttrs().getAttribute()) { - // Extensions are top level declarations, for which the literally lowest - // access level `private` is equivalent to `fileprivate`. - AccessLevel extAccess = std::max(extAttr->getAccess(), - AccessLevel::FilePrivate); - if (attr->getAccess() > extAccess) { + AccessLevel defaultAccess = extension->getDefaultAccessLevel(); + if (attr->getAccess() > defaultAccess) { auto diag = TC.diagnose(attr->getLocation(), diag::access_control_ext_member_more, attr->getAccess(), D->getDescriptiveKind(), extAttr->getAccess()); - bool shouldNotReplace = isRedundantAttrInExtension(extAccess, extAttr); - swift::fixItAccess(diag, cast(D), extAccess, false, - shouldNotReplace); + swift::fixItAccess(diag, cast(D), defaultAccess, false, + true); return; - } - if (isRedundantAttrInExtension(attr->getAccess(), extAttr)) { + } else if (attr->getAccess() == defaultAccess) { TC.diagnose(attr->getLocation(), diag::access_control_ext_member_redundant, attr->getAccess(), @@ -1576,6 +1564,15 @@ AttributeChecker::visitSetterAccessAttr(SetterAccessAttr *attr) { getterAccess, storageKind, attr->getAccess()); attr->setInvalid(); return; + + } else if (attr->getAccess() == getterAccess) { + TC.diagnose(attr->getLocation(), + diag::access_control_setter_redundant, + attr->getAccess(), + D->getDescriptiveKind(), + getterAccess) + .fixItRemove(attr->getRange()); + return; } } diff --git a/test/Compatibility/accessibility.swift b/test/Compatibility/accessibility.swift index e6b83078d77..a63f103c51b 100644 --- a/test/Compatibility/accessibility.swift +++ b/test/Compatibility/accessibility.swift @@ -89,8 +89,8 @@ fileprivate extension PublicStruct { private func extImplFilePrivate() {} } private extension PublicStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension InternalStruct { // expected-error {{extension of internal struct cannot be declared public}} {{1-8=}} @@ -109,8 +109,8 @@ fileprivate extension InternalStruct { private func extImplFilePrivate() {} } private extension InternalStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension FilePrivateStruct { // expected-error {{extension of fileprivate struct cannot be declared public}} {{1-8=}} @@ -129,8 +129,8 @@ fileprivate extension FilePrivateStruct { private func extImplFilePrivate() {} } private extension FilePrivateStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension PrivateStruct { // expected-error {{extension of private struct cannot be declared public}} {{1-8=}} @@ -149,8 +149,8 @@ fileprivate extension PrivateStruct { // expected-error {{extension of private s private func extImplFilePrivate() {} } private extension PrivateStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } @@ -716,3 +716,90 @@ public typealias BadPublicComposition2 = PublicClass & InternalProto // expected public typealias BadPublicComposition3 = InternalGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} public typealias BadPublicComposition4 = InternalGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} public typealias BadPublicComposition5 = PublicGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} + + +open class ClassWithProperties { + open open(set) var openProp = 0 // expected-warning {{'open(set)' modifier is redundant for an open property}} {{8-18=}} + public public(set) var publicProp = 0 // expected-warning {{'public(set)' modifier is redundant for a public property}} {{10-22=}} + internal internal(set) var internalProp = 0 // expected-warning {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + fileprivate fileprivate(set) var fileprivateProp = 0 // expected-warning {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + private private(set) var privateProp = 0 // expected-warning {{'private(set)' modifier is redundant for a private property}} {{11-24=}} + internal(set) var defaultProp = 0 // expected-warning {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} +} + +extension ClassWithProperties { + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + internal internal(set) var defaultExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} + internal(set) var defaultExtProp2: Int { + get { return 42 } + set {} + } +} + +public extension ClassWithProperties { + // expected-warning@+2 {{'public' modifier is redundant for property declared in a public extension}} {{3-10=}} + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{10-22=}} + public public(set) var publicExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{3-15=}} + public(set) var publicExtProp2: Int { + get { return 42 } + set {} + } +} + +internal extension ClassWithProperties { + // expected-warning@+2 {{'internal' modifier is redundant for property declared in an internal extension}} {{3-12=}} + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + internal internal(set) var internalExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} + internal(set) var internalExtProp2: Int { + get { return 42 } + set {} + } +} + +fileprivate extension ClassWithProperties { + // expected-warning@+2 {{'fileprivate' modifier is redundant for property declared in a fileprivate extension}} {{3-15=}} + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + fileprivate fileprivate(set) var fileprivateExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{3-20=}} + fileprivate(set) var fileprivateExtProp2: Int { + get { return 42 } + set {} + } + private(set) var fileprivateExtProp3: Int { + get { return 42 } + set {} + } +} + +private extension ClassWithProperties { + // expected-warning@+2 {{'fileprivate' modifier is redundant for property declared in a private (equivalent to fileprivate) extension}} {{3-15=}} + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + fileprivate fileprivate(set) var privateExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{3-20=}} + fileprivate(set) var privateExtProp2: Int { + get { return 42 } + set {} + } + private(set) var privateExtProp3: Int { + get { return 42 } + set {} + } +} diff --git a/test/Compatibility/tuple_arguments_4.swift b/test/Compatibility/tuple_arguments_4.swift index b09b9be56a0..c5316d3af4c 100644 --- a/test/Compatibility/tuple_arguments_4.swift +++ b/test/Compatibility/tuple_arguments_4.swift @@ -1631,15 +1631,13 @@ do { // https://bugs.swift.org/browse/SR-6509 public extension Optional { - // expected-warning@+1 {{'public' modifier is redundant for instance method declared in a public extension}} - public func apply(_ transform: ((Wrapped) -> Result)?) -> Result? { + func apply(_ transform: ((Wrapped) -> Result)?) -> Result? { return self.flatMap { value in transform.map { $0(value) } } } - // expected-warning@+1 {{'public' modifier is redundant for instance method declared in a public extension}} - public func apply(_ value: Value?) -> Result? + func apply(_ value: Value?) -> Result? where Wrapped == (Value) -> Result { return value.apply(self) } diff --git a/test/Constraints/tuple_arguments.swift b/test/Constraints/tuple_arguments.swift index 1d9aaaae87f..8f58255978a 100644 --- a/test/Constraints/tuple_arguments.swift +++ b/test/Constraints/tuple_arguments.swift @@ -1632,15 +1632,13 @@ do { // https://bugs.swift.org/browse/SR-6509 public extension Optional { - // expected-warning@+1 {{'public' modifier is redundant for instance method declared in a public extension}} - public func apply(_ transform: ((Wrapped) -> Result)?) -> Result? { + func apply(_ transform: ((Wrapped) -> Result)?) -> Result? { return self.flatMap { value in transform.map { $0(value) } } } - // expected-warning@+1 {{'public' modifier is redundant for instance method declared in a public extension}} - public func apply(_ value: Value?) -> Result? + func apply(_ value: Value?) -> Result? where Wrapped == (Value) -> Result { return value.apply(self) } diff --git a/test/SILGen/accessibility_warnings.swift b/test/SILGen/accessibility_warnings.swift index d154fed4657..db0d236847a 100644 --- a/test/SILGen/accessibility_warnings.swift +++ b/test/SILGen/accessibility_warnings.swift @@ -15,6 +15,7 @@ internal struct InternalStruct { public private(set) var publicVarPrivateSet = 0 + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{10-22=}} public public(set) var publicVarPublicSet = 0 // CHECK-DAG: sil hidden @$S22accessibility_warnings14InternalStructV16publicVarGetOnlySivg @@ -56,6 +57,13 @@ extension PrivateStruct { public var publicVarExtension: Int { get { return 0 } set {} } } +public extension PublicStruct { + // CHECK-DAG: sil @$S22accessibility_warnings12PublicStructV09extMemberC0yyF + public func extMemberPublic() {} // expected-warning {{'public' modifier is redundant for instance method declared in a public extension}} {{3-10=}} + // CHECK-DAG: sil private @$S22accessibility_warnings12PublicStructV07extImplC033_5D2F2E026754A901C0FF90C404896D02LLyyF + private func extImplPublic() {} +} + internal extension PublicStruct { // CHECK-DAG: sil hidden @$S22accessibility_warnings12PublicStructV17extMemberInternalyyF public func extMemberInternal() {} // expected-warning {{declaring a public instance method in an internal extension}} {{3-10=}} @@ -64,7 +72,7 @@ internal extension PublicStruct { } private extension PublicStruct { // CHECK-DAG: sil private @$S22accessibility_warnings12PublicStructV16extMemberPrivate33_5D2F2E026754A901C0FF90C404896D02LLyyF - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} // CHECK-DAG: sil private @$S22accessibility_warnings12PublicStructV14extImplPrivate33_5D2F2E026754A901C0FF90C404896D02LLyyF private func extImplPrivate() {} } @@ -77,7 +85,7 @@ internal extension InternalStruct { } private extension InternalStruct { // CHECK-DAG: sil private @$S22accessibility_warnings14InternalStructV16extMemberPrivate33_5D2F2E026754A901C0FF90C404896D02LLyyF - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} // CHECK-DAG: sil private @$S22accessibility_warnings14InternalStructV14extImplPrivate33_5D2F2E026754A901C0FF90C404896D02LLyyF private func extImplPrivate() {} } @@ -85,7 +93,7 @@ private extension InternalStruct { private extension PrivateStruct { // CHECK-DAG: sil private @$S22accessibility_warnings13PrivateStruct33_5D2F2E026754A901C0FF90C404896D02LLV09extMemberC0yyF - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} // CHECK-DAG: sil private @$S22accessibility_warnings13PrivateStruct33_5D2F2E026754A901C0FF90C404896D02LLV07extImplC0yyF private func extImplPrivate() {} } @@ -120,6 +128,7 @@ internal class InternalClass { // CHECK-DAG: sil hidden [transparent] @$S22accessibility_warnings13InternalClassC19publicVarPrivateSetSivg public private(set) var publicVarPrivateSet = 0 + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{10-22=}} public public(set) var publicVarPublicSet = 0 // CHECK-DAG: sil hidden @$S22accessibility_warnings13InternalClassC16publicVarGetOnlySivg diff --git a/test/Sema/accessibility.swift b/test/Sema/accessibility.swift index 84dfa09e927..4f2ec703476 100644 --- a/test/Sema/accessibility.swift +++ b/test/Sema/accessibility.swift @@ -89,8 +89,8 @@ fileprivate extension PublicStruct { private func extImplFilePrivate() {} } private extension PublicStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension InternalStruct { // expected-error {{extension of internal struct cannot be declared public}} {{1-8=}} @@ -109,8 +109,8 @@ fileprivate extension InternalStruct { private func extImplFilePrivate() {} } private extension InternalStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension FilePrivateStruct { // expected-error {{extension of fileprivate struct cannot be declared public}} {{1-8=}} @@ -129,8 +129,8 @@ fileprivate extension FilePrivateStruct { private func extImplFilePrivate() {} } private extension FilePrivateStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } public extension PrivateStruct { // expected-error {{extension of private struct cannot be declared public}} {{1-8=}} @@ -149,8 +149,8 @@ fileprivate extension PrivateStruct { // expected-error {{extension of private s private func extImplFilePrivate() {} } private extension PrivateStruct { - public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-9=fileprivate}} - fileprivate func extFuncPrivate() {} + public func extMemberPrivate() {} // expected-warning {{declaring a public instance method in a private extension}} {{3-10=}} + fileprivate func extFuncPrivate() {} // expected-warning {{'fileprivate' modifier is redundant for instance method declared in a private (equivalent to fileprivate) extension}} {{3-15=}} private func extImplPrivate() {} } @@ -724,3 +724,90 @@ public typealias BadPublicComposition2 = PublicClass & InternalProto // expected public typealias BadPublicComposition3 = InternalGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} public typealias BadPublicComposition4 = InternalGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} public typealias BadPublicComposition5 = PublicGenericClass & PublicProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}} + + +open class ClassWithProperties { + open open(set) var openProp = 0 // expected-warning {{'open(set)' modifier is redundant for an open property}} {{8-18=}} + public public(set) var publicProp = 0 // expected-warning {{'public(set)' modifier is redundant for a public property}} {{10-22=}} + internal internal(set) var internalProp = 0 // expected-warning {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + fileprivate fileprivate(set) var fileprivateProp = 0 // expected-warning {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + private private(set) var privateProp = 0 // expected-warning {{'private(set)' modifier is redundant for a private property}} {{11-24=}} + internal(set) var defaultProp = 0 // expected-warning {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} +} + +extension ClassWithProperties { + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + internal internal(set) var defaultExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} + internal(set) var defaultExtProp2: Int { + get { return 42 } + set {} + } +} + +public extension ClassWithProperties { + // expected-warning@+2 {{'public' modifier is redundant for property declared in a public extension}} {{3-10=}} + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{10-22=}} + public public(set) var publicExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'public(set)' modifier is redundant for a public property}} {{3-15=}} + public(set) var publicExtProp2: Int { + get { return 42 } + set {} + } +} + +internal extension ClassWithProperties { + // expected-warning@+2 {{'internal' modifier is redundant for property declared in an internal extension}} {{3-12=}} + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{12-26=}} + internal internal(set) var internalExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'internal(set)' modifier is redundant for an internal property}} {{3-17=}} + internal(set) var internalExtProp2: Int { + get { return 42 } + set {} + } +} + +fileprivate extension ClassWithProperties { + // expected-warning@+2 {{'fileprivate' modifier is redundant for property declared in a fileprivate extension}} {{3-15=}} + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + fileprivate fileprivate(set) var fileprivateExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{3-20=}} + fileprivate(set) var fileprivateExtProp2: Int { + get { return 42 } + set {} + } + private(set) var fileprivateExtProp3: Int { + get { return 42 } + set {} + } +} + +private extension ClassWithProperties { + // expected-warning@+2 {{'fileprivate' modifier is redundant for property declared in a private (equivalent to fileprivate) extension}} {{3-15=}} + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{15-32=}} + fileprivate fileprivate(set) var privateExtProp: Int { + get { return 42 } + set {} + } + // expected-warning@+1 {{'fileprivate(set)' modifier is redundant for a fileprivate property}} {{3-20=}} + fileprivate(set) var privateExtProp2: Int { + get { return 42 } + set {} + } + private(set) var privateExtProp3: Int { + get { return 42 } + set {} + } +}