Unexpected failure to open constrained existential #66794
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
constrained existentials
Feature → existentials: constrained existentials such as 'any Collection<Int>'
existential member accesses
Feature → existentials: existential member accesses
existentials
Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values
implicit existential opening
Feature → existentials: implicit opening of existentials when passed to parameters of generic type
parameterized protocols
Feature → protocol: protocols with primary associated types
swift 5.9
type checker
Area → compiler: Semantic analysis
Description
Removing the constraint
A: C
allows the code to compile.Replacing the direct call to the protocol function with something that opens the existential in argument position produces a different error (that makes me want to slap the compiler for being oblivious to the obvious):
Expected behavior
Pretty sure both these samples should compile; the constraint of the struct's generic argument shouldn't affect opening to the less-constrained protocol.
(When I originally encountered this, the protocol also had a constraint of the associated type to
AnyObject
; that doesn't seem relevant to the test case but might be to the general solution?)Environment
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
The text was updated successfully, but these errors were encountered: