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-13110] Circular reference after updating to Xcode 11.5 #55556

Closed
swift-ci opened this issue Jun 29, 2020 · 2 comments
Closed

[SR-13110] Circular reference after updating to Xcode 11.5 #55556

swift-ci opened this issue Jun 29, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13110
Radar https://feedbackassistant.apple.com/feedback/7819220
Original Reporter otaviolima (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @CodaFi
Priority Medium

md5: a7393606167d59ee99509e62a32d87ee

Issue Description:

Consider the following code:

protocol A {}
protocol B {}

class Clazz: B, Clazz.TypeAlias {    
  typealias TypeAlias = A
}

The above code compiles fine on Xcode 11.3.1 toolchain but fails on Xcode 11.5.

circular.swift:5:7: error: circular reference
class Clazz: B, Clazz.TypeAlias {
      ^
circular.swift:5:23: note: through reference here
class Clazz: B, Clazz.TypeAlias {
                      ^
circular.swift:5:7: error: circular reference
class Clazz: B, Clazz.TypeAlias {
      ^
circular.swift:6:13: note: through reference here
  typealias TypeAlias = A
            ^
[...redacted...] 

However, if protocol B is changed to be class B, like the following:

protocol A {}
class B {}

class Clazz: B, Clazz.TypeAlias {    
  typealias TypeAlias = A
}

Then both toolchains are able to compile the code.

I expected both snippets to fail to compile with the same/similar error when using Xcode 11.5+.

@swift-ci
Copy link
Collaborator Author

Comment by Otávio Lima (JIRA)

Same results on Xcode 12.0 Beta

@CodaFi
Copy link
Member

CodaFi commented Jul 2, 2020

This happened to work by accident in prior versions of Swift, as you have observed. The inheritance clause this produces is very circular.

class Clazz: B, Clazz.TypeAlias {
typealias TypeAlias = A
}

In order to resolve Clazz' inheritance clause, we need to resolve Clazz.TypeAlias, so we need to resolve the base Clazz, which is what we're trying to accomplish in the first place. Whatever prior versions of Swiftc happened to do here may have been desirable in some cases, but its behavior was not guaranteed to be stable.

@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
Projects
None yet
Development

No branches or pull requests

2 participants