Files
swift-mirror/test/IRGen/windows-lazy-initialize-conformance.swift
Saleem Abdulrasool 915b1664c5 IRGen: use the accessor conformance on Windows
When building with lazy initialization of the root conformance, we need
to ensure that we are invoking the accessor to initialize the
conformance record.  We would previously generate a direct reference to
the conformance, which was uninitialized, resulting in a crash at
runtime.

The non-windows test changes here are to use/imply static linking for
the support modules.  This should have no difference on the non-Windows
targets, but makes a difference on Windows where this implies that
everything will be built into a single module, which permits the
non-indirect access to types.  Unfortunately, this does somewhat regress
the test coverage on Windows as we do not exercise as much of the shared
linkage paths which do change some of the code-generation to deal with
the moral equivalent of the GOT - the IAT.

Special thanks to @slavapestov for the pointer to
`isDependentConformance`.  This should eliminate the last known issue
with cross-module protocol conformances.

Fixes: SR-14807
2021-11-05 08:32:46 -07:00

28 lines
578 B
Swift

// RUN: %target-swift-frontend -S -emit-ir %s -o - | %FileCheck %s
// REQUIRES: OS=windows-msvc
class C {
static func encode(_ c: Encodable) throws {}
}
public protocol P: Codable {}
extension String: P {}
public enum E {
case associated(P)
}
extension E: Encodable {
public func encode(to encoder: Encoder) throws {
switch self {
case .associated(let p):
try p.encode(to: encoder)
}
}
}
try? print(C.encode(E.associated("string")))
// CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @"$sSS4main1PAAWP", i32 0, i32 0), i8***