Files
swift-mirror/test/Interpreter/protocol_composition_with_markers.swift
Pavel Yaskevich 5d243bd8a2 [IRGen] Move marker protocol stripping from mangleTypeSymbol to mangleTypeForFlatUniqueTypeRef
The original check introduced by https://github.com/apple/swift/pull/71855
is too broad. For concrete metadata we call the runtime demangler so
we need to strip off marker protocols when mangling that string and
`mangleTypeForReflection` already does that.
2024-06-04 21:58:59 -07:00

61 lines
870 B
Swift

// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
protocol P {
init()
func f()
}
class C: P {
required init() {}
func f() { print("C.f") }
}
struct G<T: P> {
func f() { T().f() }
}
G<any (C & Sendable)>().f()
// CHECK: C.f
do {
let v1 = (any C & Sendable).self
let v2 = C.self
print(v1)
// CHECK: C
print(v2)
// CHECK: C
print(v1 == v2)
// CHECK: true
}
@_marker
protocol Marker {
}
do {
print(G<any (C & Sendable)>.self)
// CHECK: G<C>
class D<T> {
}
print((D<Int> & Sendable).self)
// CHECK: D<Int>
print((D<C & Marker> & Sendable).self)
// CHECK: D<C>
print((any Marker & Sendable).self)
// CHECK: Any
print((AnyObject & Sendable & Marker).self)
// CHECK: AnyObject
func generic<T>(_: T.Type) {
print((D<T> & Sendable).self)
}
generic(Int.self)
// CHECK: D<Int>
}