Compiler error when extending a typealias of a partially specialized generic type
#88835 opened on May 5, 2026
Description
Description When creating a typealias that partially specializes a generic type, the compiler generates an error when attempting to extend that type via the typealias.
Steps to reproduce Create a Generic type with two type parameters.
struct Field<Tag,Value> {
let tag: Tag
let value: Value
}
Define a typealias which specializes one of the type parameters as such :
typealias IntField<Tag> = Field<Tag,Int>
Define an extension based on the typealias:
extension IntField {
func adding(_ value: Int) -> Self {
Field(tag: tag, value: self.value + value)
}
}
Expected behavior I would expect this code to compile.
Instead the compiler complained: "Binary operator '+' cannot be applied to operands of type 'Value' and 'Int'"
If instead of extending the typealias, I extend the type directly it compiles fine as such:
extension Field where Value == Int {
func adding(_ value: Int) -> Self {
Field(tag: tag, value: self.value + value)
}
}
Environment
- Swift compiler version info swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
- Xcode version info: Xcode 14.3.1 Build version 14E300c
- Deployment target: macOS Playground
Additional context Not a duplicate of #47452 , since #47452 passes a string as argument, but it is constrained to only accept Int.
Feel free to close this if mistaken.