Files
swift-mirror/validation-test/Evolution/Inputs/keypaths.swift.gyb
Joe Groff 53e8e7b1d8 SILGen: Don't reference external property descriptors for @_alwaysEmitIntoClient properties.
Their definition is fully visible to clients to be copied into them, and there isn't necessarily
a symbol for the property descriptor in the defining module, so it isn't necessary or desirable to
try to use a property descriptor with them. Trying to reference the descriptor leads to missing
symbol errors at load time when trying to use keypaths with older versions of the defining dylib,
which goes against the purpose of `@_alwaysEmitIntoClient` meaning "no ABI liabilities for the
defining module". Fixes rdar://94049160.
2022-06-01 16:54:38 -07:00

132 lines
2.4 KiB
Swift

%{
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
}
public struct AEIC {
#if AFTER
@_alwaysEmitIntoClient
public var aeic: Int { return 0 }
#endif
}