I have this code that I assume should work but it crashes the compiler (Apple Swift version 6.2-dev (LLVM 162ee50b401fff2, Swift 57288d13c9f3c02) in xcode 16.3 beta 2)
I'm trying to restrict the PropertyType of PropertyAnimatorTuple to be the same as all its elements T. Slight variations of the code gives different compiler errors but the one below crashes the compiler. @simanerush @hborla is this supposed to work?
public protocol TypedAnimateable {
}
extension Int: TypedAnimateable {
}
struct IntProp: PropertyAnimator {
typealias PropertyType = Int
}
struct OtherIntProp: PropertyAnimator {
typealias PropertyType = Int
}
public struct PropertyAnimatorTuple<PropertyType: TypedAnimateable, each T: PropertyAnimator>: PropertyAnimator
where repeat (each T).PropertyType == PropertyType {
public typealias PropertyType = PropertyType
let theValue: (repeat each T)
init(_ value: repeat each T) {
// self.theValue = (repeat each value)
fatalError("the line above also doesnt work no matter where I put the parenthesis")
}
}
func tester() {
// let prop = PropertyAnimatorTuple<Int, IntProp, OtherIntProp>(IntProp(), OtherIntProp()) // this doesnt work. The compiler compains that "Int" and "Int, Int" is not equal.
let prop: PropertyAnimatorTuple<Int, IntProp, OtherIntProp> = propThing(IntProp(), OtherIntProp())
}
func propThing<each T: PropertyAnimator, PropertyType: TypedAnimateable>(_ value: (repeat each T)) where repeat (each T).PropertyType == PropertyType -> PropertyAnimatorTuple<PropertyType, each T> {
return PropertyAnimatorTuple<PropertyType,each T>(repeat each value)
}