Files
swift-mirror/test/Sema/copyable_conformance_diff_source_file.swift
Kavon Farvardin 233742a565 NCGenerics: enforce same-source conformance rule
SE-427 says the conformance to Copyable must appear in the same source
file as the nominal type.

resolves rdar://131486561
2024-07-10 14:02:10 -07:00

21 lines
577 B
Swift

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
//// Ensure we cannot add the conformance in a different source file.
// RUN: %target-swift-frontend \
// RUN: -typecheck -verify \
// RUN: %t/Visitor.swift %t/GardenKit.swift
//--- GardenKit.swift
public struct Garden<Plant: ~Copyable>: ~Copyable {
public let plant: Plant
public init(_ p: consuming Plant) { plant = p }
}
//--- Visitor.swift
// expected-error@+1 {{conformance to 'Copyable' must occur in the same source file as generic struct 'Garden'}}
extension Garden: Copyable where Plant: Copyable {}