Skip to content

Conversation

@DanilKoshnarev
Copy link

When extending a partially specialized generic typealias (e.g., 'typealias IntField = Field<Tag, Int>'), the compiler was losing type specialization information and returning only the base nominal type (Field<Tag, Value>), causing type checker errors when trying to use specialized type information in the extension body.

This fix ensures that we return the typealias type itself, which properly preserves the partial specialization constraints.

The previous logic used isPassThroughTypealias() to decide between returning extendedType or extendedNominal->getDeclaredType(). When the latter was returned, it lost the specialization information (e.g., that Value == Int in IntField).

By always returning extendedType for typealias extensions, we preserve the full type information and allow the type checker to correctly resolve types in the extension body.

Fixes: #68212

…extensions

When extending a partially specialized generic typealias (e.g.,
'typealias IntField<Tag> = Field<Tag, Int>'), the compiler was
losing type specialization information and returning only the
base nominal type (Field<Tag, Value>), causing type checker
errors when trying to use specialized type information in the
extension body.

This fix ensures that we return the typealias type itself,
which properly preserves the partial specialization constraints.

The previous logic used isPassThroughTypealias() to decide between
returning extendedType or extendedNominal->getDeclaredType(). When
the latter was returned, it lost the specialization information
(e.g., that Value == Int in IntField<Tag>).

By always returning extendedType for typealias extensions, we
preserve the full type information and allow the type checker
to correctly resolve types in the extension body.

Fixes: swiftlang#68212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler error when extending a typealias of a partially specialized generic type

1 participant