[SR-8713] Protocol extension methods invoked from non-final classes are type-checked incorrectly #51225
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 027eff7f9618cd5c78a13cf89a0cfa28
Issue Description:
The following code type checks, but is unsound and should be rejected:
Specifically, inside
Animal.init(with: )
the callself.init(_with: instance)
should be invoking the protocol extension methodP.init(_with: )
with/*protocol*/ Self == /*dynamic*/ Self
, but the type checker checks it as ifSelf == Animal
, allowing the initializer to unsoundly initializeself
with a differentAnimal
type from the dynamicSelf
it was invoked on.The text was updated successfully, but these errors were encountered: