Files
swift-mirror/test/Runtime/lazy_witness_table_cycle.swift
Doug Gregor 229ddf570f [IRGen] Metadata for the conforming type in a witness table access need not be complete.
When calling a witness table accessor, IRGen was forcing the
conforming type to have complete metadata, even though only abstract
metadata is required for that query. This could cause cyclic metadata
dependencies when checking conditional conformances.

Fixes SR-5958.
2019-02-05 22:02:49 -08:00

32 lines
748 B
Swift

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop
// SR-5958
import Foundation
public struct Property: Equatable, Hashable, Codable {
public var value: PropertyValue<Property>
}
public enum PropertyValue<P>: Equatable, Hashable where P: Equatable & Hashable {
case invalid
case date(date: Date?)
}
extension PropertyValue: Codable where P: Codable {
public func encode(to encoder: Encoder) throws {}
public init(from decoder: Decoder) throws { self = .invalid }
}
extension String: Error {}
let encoder = JSONEncoder()
let json = try! encoder.encode(
Property(value: .invalid)
)
let decoder = JSONDecoder()
let result = try! decoder.decode(Property.self, from: json)
print(result)