Files
swift-mirror/test/Generics/parameter-pack-same-element-requirements.swift
Daniel Rodríguez Troitiño ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00

60 lines
1.9 KiB
Swift

// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -enable-experimental-feature SameElementRequirements -disable-availability-checking 2>&1 | %FileCheck %s -dump-input=fail
// REQUIRES: swift_feature_SameElementRequirements
protocol P {
associatedtype A
func f(_ self: Self) -> Self
}
//////
///
/// Same-element requirements.
///
//////
// FIXME: Implement concrete same-type requirements.
//func sameElementConcrete<each T>(
// _: repeat each T
//) where repeat each T == Int {}
// CHECK-LABEL: sameElementGeneric
// CHECK-NEXT: Generic signature: <each T, U where repeat each T == U>
func sameElementGeneric<each T, U>(
_: repeat each T
) where repeat each T == U {}
// FIXME: Implement concrete same-element requirements.
//func dependentSameElementConcrete<each C: Collection>(
// _: repeat each C
//) where repeat (each C).Element == Int {}
// CHECK-LABEL: dependentSameElementGeneric
// CHECK-NEXT: Generic signature: <each C, Element where repeat each C : Collection, repeat Element == (each C).[Sequence]Element>
func dependentSameElementGeneric<each C: Collection, Element>(
_: repeat each C
) where repeat (each C).Element == Element {}
// FIXME: Either 'repeat each T: P' or 'U: P' should be redundant.
// CHECK-LABEL: sameElementRedundantConformance
// CHECK-NEXT: Generic signature: <each T, U where repeat each T : P, repeat each T == U, U : P>
func sameElementRedundantConformance<each T, U>(
t: repeat each T,
u: U
) where repeat each T: P,
repeat each T == U {
let _ = (repeat (each t).f(u))
}
// CHECK-LABEL: forEachEach
// CHECK-NEXT: Generic signature: <each C, U where repeat each C : Collection, repeat U == (each C).[Sequence]Element>
func forEachEach<each C, U>(
c: repeat each C,
function: (U) -> Void
) where repeat each C: Collection,
repeat (each C).Element == U {
repeat (each c).forEach(function)
}