Navigation Menu

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-7435] Compiler incorrectly disallows nonfinal classes from using default implementations that have same-type constraints on associated types of Self #49978

Closed
jckarter opened this issue Apr 13, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.1 type checker Area → compiler: Semantic analysis

Comments

@jckarter
Copy link
Member

Previous ID SR-7435
Radar rdar://problem/39419121
Original Reporter @jckarter
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.1Regression, TypeChecker
Assignee None
Priority Medium

md5: 54e4c4d933929ccd0bf5a956a29ab02c

duplicates:

  • SR-7428 Class conforming to protocol with default method implementation no longer compiles with Xcode 9.3

Issue Description:

This used to compile in 4.0, but gets rejected in 4.1 and master:

protocol A {
  associatedtype B
  func foo<C: A>(_: C) where C.B == Self.B

  func bar() -> B
}

extension A {
  func foo<C: A>(_: C) where C.B == Self.B {}
}

class D: A {
  func bar() -> Int { return 0 }
}

Although it would be correct to reject a protocol extension method with a same-type constraint on Self as a witness for a non-final class, it is not correct to do so for associated types of Self, since those come from the conformance and ought to be invariant among all subclasses of a conforming type. I found this regression while attempting to build an embedded version of Realm with Xcode 9.3 as part of reproducing another crash.

@jckarter
Copy link
Member Author

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.1 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants