mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We'd really like to say that private decls can't affect other files,
but we don't have enough information at parse-time:
- Private members of non-private classes still show up in vtables,
which affects subclasses and callers in other files.
- Private stored properties of non-private structs change the
layout of the struct.
- Private types may be used in private stored properties, affecting
the layout of the containing struct.
- Private decls of /any kind/ can be used as the initial value of a
stored property without an explicit type.
private class Evil {
class func defaultAlignment() -> Alignment { return .evil }
}
public struct Character {
// Inferred type here!
private var alignment = Evil.defaultAlignment()
}
To be safe and correct, go back to only ignoring method bodies.
https://bugs.swift.org/browse/SR-1030
25 lines
453 B
Swift
25 lines
453 B
Swift
// RUN: mkdir -p %t
|
|
// RUN: %utils/split_file.py -o %t %s
|
|
// RUN: %target-swift-frontend -dump-interface-hash %t/a.swift 2> %t/a.hash
|
|
// RUN: %target-swift-frontend -dump-interface-hash %t/b.swift 2> %t/b.hash
|
|
// RUN: not cmp %t/a.hash %t/b.hash
|
|
|
|
// BEGIN a.swift
|
|
private struct S {
|
|
func f2() -> Int {
|
|
return 0
|
|
}
|
|
|
|
var y: Int = 0
|
|
}
|
|
|
|
// BEGIN b.swift
|
|
private struct S {
|
|
func f2() -> Int {
|
|
return 0
|
|
}
|
|
|
|
var x: Int = 0
|
|
var y: Int = 0
|
|
}
|