[SR-7336] Protocol with same-type constraint on associated type "can only be used as generic constraint" #49884
Labels
compiler
The Swift compiler in itself
duplicate
Resolution: Duplicates another issue
existentials
Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values
feature
A feature request or implementation
improvement
swift evolution implemented
Flag → feature: A feature that was approved through the Swift evolution process and implemented
type checker
Area → compiler: Semantic analysis
Environment
Xcode Version 9.2 (9C40b)
Additional Detail from JIRA
md5: 0e0706f8b1ded96651a61cd786f858cb
duplicates:
Issue Description:
Frustrating to meet this bug...Since
Action
is defined (in a mathematical sense), I should be able to useP1
as any other protocol without associated types.I understand same-type constraints as semantic refinements rather that defaulting acts. The difference is that the former are irreversible.
is not the same as
In the first example I specify a default type for
Action
. This means I can have a different default in an inheriting protocol. Conversely, in the second example I constrainAction
toString
. In other words,Action
becomes atypealias
that can't be overridden or changed further in the protocol hierarchy.However, it is possible to "override"
Action
even after same-type constraining it, which is very strange to me.This might be the reason I can't use a protocol with a same-type constraint on it's associated type anywhere other that a generic constraint, or just another bug.
The text was updated successfully, but these errors were encountered: