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

Add a test for using a nested type for a base class generic argument #23920

Merged
merged 1 commit into from
Apr 10, 2019

Conversation

jrose-apple
Copy link
Contributor

This used to cause an infinite loop in the compiler but now works fine.

SR-9160

This used to cause an infinite loop in the compiler but now works fine.

https://bugs.swift.org/browse/SR-9160
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@Sajjon
Copy link

Sajjon commented Apr 10, 2019

@jrose-apple Nice! Only just four hours ago I found a related regression bug. Give me a couple of minutes and I will paste relevant code. Regression as in code that worked fine with Swift 4.2 but not with Swift 5.0

@Sajjon
Copy link

Sajjon commented Apr 10, 2019

Sorry, I gave it a go but did not manage to reproduce using a minimum example.

The issue involves something like this:

protocol FoobarProtocol {
    associatedtype Foo
    func createFoo() -> Foo
}

class AbstractClass<FooInAbstract>: FooBarProtocol {
    func createFoo() -> FooInAbstract { fatalError("impl me") }
}

class BaseClass<FooInBase>: AbstractClass<FooInBase> {
  // Other base functions
}

final class ConcreteClass: BaseClass<Foo> {
    struct Foo {}
    override func createFoo() -> Foo { return Foo() }
} 

Something like that worked fine with Swift 4.2 but causing issues in Swift 5. I think it was when I referenced the type Foo that I got issues with Swift 5, where it failed to disambiguate between the declared associatedtype Foo and the concrete nested struct Foo inside ConcreteClass.

(For sake of completeness for future readers it is in my app Zhip (which is open sourcee)) in the branch swift5 where I discovered this regresssion bug)

@jrose-apple
Copy link
Contributor Author

Please file a bug, even if you just link to a specific commit of your project!

@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants