mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SIL] Only open classes can be subclassed externally.
This commit is contained in:
@@ -870,8 +870,8 @@ SubclassScope SILDeclRef::getSubclassScope() const {
|
|||||||
case Accessibility::FilePrivate:
|
case Accessibility::FilePrivate:
|
||||||
return SubclassScope::NotApplicable;
|
return SubclassScope::NotApplicable;
|
||||||
case Accessibility::Internal:
|
case Accessibility::Internal:
|
||||||
return SubclassScope::Internal;
|
|
||||||
case Accessibility::Public:
|
case Accessibility::Public:
|
||||||
|
return SubclassScope::Internal;
|
||||||
case Accessibility::Open:
|
case Accessibility::Open:
|
||||||
return SubclassScope::External;
|
return SubclassScope::External;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,24 @@ extension Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class PublicClass {
|
public class PublicClass {
|
||||||
// CHECK: define{{( protected)?}} swiftcc void @_T014method_linkage11PublicClass{{.*}}4pfoo0
|
// CHECK: define hidden swiftcc void @_T014method_linkage11PublicClass{{.*}}4pfoo0
|
||||||
@inline(never)
|
@inline(never)
|
||||||
fileprivate func pfoo() {
|
fileprivate func pfoo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: define{{( protected)?}} swiftcc void @_T014method_linkage11PublicClassC4pbaryyF
|
// CHECK: define hidden swiftcc void @_T014method_linkage11PublicClassC4pbaryyF
|
||||||
|
@inline(never)
|
||||||
|
internal func pbar() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class OpenClass {
|
||||||
|
// CHECK: define{{( protected)?}} swiftcc void @_T014method_linkage9OpenClass{{.*}}4pfoo0
|
||||||
|
@inline(never)
|
||||||
|
fileprivate func pfoo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: define{{( protected)?}} swiftcc void @_T014method_linkage9OpenClassC4pbaryyF
|
||||||
@inline(never)
|
@inline(never)
|
||||||
internal func pbar() {
|
internal func pbar() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
<unknown>:0: error: symbol '_T04test13PublicMethodsC13privateMethod33_C78BF7A60640620A6DFBB107F4401C5CLLyyF' (test.PublicMethods.(privateMethod in _C78BF7A60640620A6DFBB107F4401C5C)() -> ()) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test11OpenMethodsC13privateMethod33_C78BF7A60640620A6DFBB107F4401C5CLLyyF' (test.OpenMethods.(privateMethod in _C78BF7A60640620A6DFBB107F4401C5C)() -> ()) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test13PublicMethodsC14internalMethodyyF' (test.PublicMethods.internalMethod() -> ()) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test11OpenMethodsC14internalMethodyyF' (test.OpenMethods.internalMethod() -> ()) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.PublicProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.OpenProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifm' (test.PublicProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifm' (test.OpenProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifs' (test.PublicProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).setter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC10privateVar33_C78BF7A60640620A6DFBB107F4401C5CLLSifs' (test.OpenProperties.(privateVar in _C78BF7A60640620A6DFBB107F4401C5C).setter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC11internalVarSifg' (test.PublicProperties.internalVar.getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC11internalVarSifg' (test.OpenProperties.internalVar.getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC11internalVarSifm' (test.PublicProperties.internalVar.materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC11internalVarSifm' (test.OpenProperties.internalVar.materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC11internalVarSifs' (test.PublicProperties.internalVar.setter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC11internalVarSifs' (test.OpenProperties.internalVar.setter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC13privateVarGet33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.PublicProperties.(privateVarGet in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC13privateVarGet33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.OpenProperties.(privateVarGet in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC14internalVarGetSifg' (test.PublicProperties.internalVarGet.getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC14internalVarGetSifg' (test.OpenProperties.internalVarGet.getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.PublicProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifg' (test.OpenProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifm' (test.PublicProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifm' (test.OpenProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifs' (test.PublicProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).setter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC16privateVarGetSet33_C78BF7A60640620A6DFBB107F4401C5CLLSifs' (test.OpenProperties.(privateVarGetSet in _C78BF7A60640620A6DFBB107F4401C5C).setter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC17internalVarGetSetSifg' (test.PublicProperties.internalVarGetSet.getter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC17internalVarGetSetSifg' (test.OpenProperties.internalVarGetSet.getter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC17internalVarGetSetSifm' (test.PublicProperties.internalVarGetSet.materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC17internalVarGetSetSifm' (test.OpenProperties.internalVarGetSet.materializeForSet : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
<unknown>:0: error: symbol '_T04test16PublicPropertiesC17internalVarGetSetSifs' (test.PublicProperties.internalVarGetSet.setter : Swift.Int) is in generated IR file, but not in TBD file
|
<unknown>:0: error: symbol '_T04test14OpenPropertiesC17internalVarGetSetSifs' (test.OpenProperties.internalVarGetSet.setter : Swift.Int) is in generated IR file, but not in TBD file
|
||||||
|
<unknown>:0: error: symbol '_T04test10PublicInitCACSi9internal__tcfc' (test.PublicInit.init(internal_: Swift.Int) -> test.PublicInit) is in TBD file, but not in generated IR
|
||||||
|
<unknown>:0: error: symbol '_T04test13PublicNothingCACycfc' (test.PublicNothing.init() -> test.PublicNothing) is in TBD file, but not in generated IR
|
||||||
|
<unknown>:0: error: symbol '_T04test13PublicStaticsCACycfc' (test.PublicStatics.init() -> test.PublicStatics) is in TBD file, but not in generated IR
|
||||||
|
<unknown>:0: error: symbol '_T04test16PublicPropertiesCACycfc' (test.PublicProperties.init() -> test.PublicProperties) is in TBD file, but not in generated IR
|
||||||
|
|||||||
@@ -2,6 +2,82 @@
|
|||||||
// RUN: not %target-swift-frontend -c -parse-as-library -module-name test -validate-tbd-against-ir %s > %t.log 2>&1
|
// RUN: not %target-swift-frontend -c -parse-as-library -module-name test -validate-tbd-against-ir %s > %t.log 2>&1
|
||||||
// RUN: diff %t.log %S/Inputs/class.log
|
// RUN: diff %t.log %S/Inputs/class.log
|
||||||
|
|
||||||
|
open class OpenNothing {}
|
||||||
|
|
||||||
|
open class OpenInit {
|
||||||
|
public init() {}
|
||||||
|
public init(public_: Int) {}
|
||||||
|
|
||||||
|
internal init(internal_: Int) {}
|
||||||
|
|
||||||
|
deinit {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class OpenMethods {
|
||||||
|
public init() {}
|
||||||
|
public func publicMethod() {}
|
||||||
|
internal func internalMethod() {}
|
||||||
|
private func privateMethod() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class OpenProperties {
|
||||||
|
public let publicLet: Int = 0
|
||||||
|
internal let internalLet: Int = 0
|
||||||
|
private let privateLet: Int = 0
|
||||||
|
|
||||||
|
public var publicVar: Int = 0
|
||||||
|
internal var internalVar: Int = 0
|
||||||
|
private var privateVar: Int = 0
|
||||||
|
|
||||||
|
public var publicVarGet: Int { return 0 }
|
||||||
|
internal var internalVarGet: Int { return 0 }
|
||||||
|
private var privateVarGet: Int { return 0 }
|
||||||
|
|
||||||
|
public var publicVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
internal var internalVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
private var privateVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class OpenStatics {
|
||||||
|
public static func publicStaticFunc() {}
|
||||||
|
internal static func internalStaticFunc() {}
|
||||||
|
private static func privateStaticFunc() {}
|
||||||
|
|
||||||
|
public static let publicLet: Int = 0
|
||||||
|
internal static let internalLet: Int = 0
|
||||||
|
private static let privateLet: Int = 0
|
||||||
|
|
||||||
|
public static var publicVar: Int = 0
|
||||||
|
internal static var internalVar: Int = 0
|
||||||
|
private static var privateVar: Int = 0
|
||||||
|
|
||||||
|
public static var publicVarGet: Int { return 0 }
|
||||||
|
internal static var internalVarGet: Int { return 0 }
|
||||||
|
private static var privateVarGet: Int { return 0 }
|
||||||
|
|
||||||
|
public static var publicVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
internal static var internalVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
private static var privateVarGetSet: Int {
|
||||||
|
get { return 0 }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class PublicNothing {}
|
public class PublicNothing {}
|
||||||
|
|
||||||
public class PublicInit {
|
public class PublicInit {
|
||||||
|
|||||||
Reference in New Issue
Block a user