Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9501] Subclass existential with predefined associated type witness should be supported as existential #51955

Closed
AnthonyLatsis opened this issue Dec 13, 2018 · 1 comment
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

Comments

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Dec 13, 2018

Previous ID SR-9501
Radar None
Original Reporter @AnthonyLatsis
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 10.1 (10B61) & master

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 075e0f26634a1fe1f91a9305b41c2dac

duplicates:

  • SR-4758 SE-0142: derived protocol that restricts associatedtype should be allowed as a variable type

Issue Description:

This is a variation of SR-4758 that I believe should be faced separately. Here, the associated type is known to be concrete through a type alias in the class component of a subclass existential (rather than through where clauses on protocol declarations that directly constraint an assoc. type).

class Class {
  typealias Assoc = Int
}
protocol Proto {
    associatedtype Assoc
}

func foo(arg: Class & Proto) {} // protocol 'Proto' can only be used as a generic constraint because it has Self or associated type requirements.
@belkadan
Copy link
Contributor

belkadan commented Dec 13, 2018

This doesn't work today, but it probably should:

class Class {
  typealias Assoc = Int
}
protocol Proto {
  associatedtype Assoc
}
class Sub: Class, Proto {
  typealias Assoc = String // shadows Class.Assoc
}

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue improvement type checker Area → compiler: Semantic analysis swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values feature A feature request or implementation and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Jan 28, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants