mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
With a few modifications: - Changing computed get-only properties into 'let's breaks resilience in other ways we need to fix independent of key path resilience - Fix the tests not to ask for impossible lib-before--client-after compatibility for changes that add API
126 lines
2.3 KiB
Plaintext
126 lines
2.3 KiB
Plaintext
|
|
%{
|
|
from keypaths_gyb import testCases
|
|
}%
|
|
|
|
public var globalSink: Int = 0
|
|
|
|
public enum AnEnum {
|
|
|
|
case unset, set(Int)
|
|
|
|
init() { self = .unset }
|
|
|
|
public var sink: Int {
|
|
get {
|
|
switch self {
|
|
case .unset:
|
|
return 0
|
|
case .set(let x):
|
|
return x
|
|
}
|
|
}
|
|
set {
|
|
self = .set(newValue)
|
|
}
|
|
}
|
|
|
|
% for (name, kind, before, after, addsAPI) in testCases:
|
|
|
|
% if kind == "mutating" or kind == "nonmutating":
|
|
|
|
#if BEFORE
|
|
${before.format(name=name, nonmutating="nonmutating")}
|
|
#else
|
|
${after.format(name=name, nonmutating="nonmutating")}
|
|
#endif
|
|
|
|
public static var keyPath_${name}: PartialKeyPath<AnEnum> { return \AnEnum.${name} }
|
|
|
|
% elif kind == "stored":
|
|
|
|
% else:
|
|
%{ raise ValueError("improper test case kind") }%
|
|
% end
|
|
|
|
% end
|
|
|
|
}
|
|
|
|
public struct AStruct {
|
|
|
|
public var sink: Int = 0
|
|
|
|
% for (name, kind, before, after, addsAPI) in testCases:
|
|
|
|
% if kind == "mutating" or kind == "nonmutating" or kind == "stored":
|
|
|
|
#if BEFORE
|
|
${before.format(name=name, nonmutating="nonmutating")}
|
|
#else
|
|
${after.format(name=name, nonmutating="nonmutating")}
|
|
#endif
|
|
|
|
public static var keyPath_${name}: PartialKeyPath<AStruct> { return \AStruct.${name} }
|
|
|
|
% else:
|
|
%{ raise ValueError("improper test case kind") }%
|
|
% end
|
|
|
|
% end
|
|
|
|
}
|
|
|
|
public class AClass {
|
|
|
|
public var sink: Int = 0
|
|
|
|
% for (name, kind, before, after, addsAPI) in testCases:
|
|
|
|
% if kind == "nonmutating" or kind == "stored":
|
|
|
|
#if BEFORE
|
|
${before.format(name=name, nonmutating="")}
|
|
#else
|
|
${after.format(name=name, nonmutating="")}
|
|
#endif
|
|
|
|
public static var keyPath_${name}: PartialKeyPath<AClass> { return \AClass.${name} }
|
|
|
|
% elif kind == "mutating":
|
|
|
|
% else:
|
|
%{ raise ValueError("improper test case kind") }%
|
|
% end
|
|
|
|
% end
|
|
|
|
}
|
|
|
|
public final class AFinalClass {
|
|
|
|
public var sink: Int = 0
|
|
|
|
% for (name, kind, before, after, addsAPI) in testCases:
|
|
|
|
% if kind == "nonmutating" or kind == "stored":
|
|
|
|
#if BEFORE
|
|
${before.format(name=name, nonmutating="")}
|
|
#else
|
|
${after.format(name=name, nonmutating="")}
|
|
#endif
|
|
|
|
public static var keyPath_${name}: PartialKeyPath<AFinalClass> { return \AFinalClass.${name} }
|
|
|
|
% elif kind == "mutating":
|
|
|
|
% else:
|
|
%{ raise ValueError("improper test case kind") }%
|
|
% end
|
|
|
|
% end
|
|
|
|
}
|
|
|