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-1663] Cannot invoke initializers required by protocols on associated types with non-root-class superclass bounds #44272

Closed
swift-ci opened this issue Jun 2, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 2, 2016

Previous ID SR-1663
Radar None
Original Reporter ssheldon (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

OSX 10.11.5, Xcode 7.3.1

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

md5: 2373eef28fcb7930939c09060e7ef3c7

is duplicated by:

  • SR-2190 Failing to constrain generic type with protocol
  • SR-2813 Required failable initializer is not recognized on NSManagedObject

Issue Description:

With the following setup:

class Foo { }
class Bar: Foo { }

protocol View {
  init(foo: String)
}

This will compile:

protocol Model {
  associatedtype V: Foo, View
}

func makeView<M: Model>(m: M) -> M.V {
  return M.V(foo: "hello")
}

However, this will not:

protocol Model {
  associatedtype V: Bar, View
}

func makeView<M: Model>(m: M) -> M.V {
  return M.V(foo: "hello")
}

All that is changed is that the superclass bound on the V associated type was changed from Foo to Bar. Compile fails with this error:

error: cannot invoke value of type 'M.V.Type' with argument list '(foo: String)'
  return M.V(foo: "hello")

I've also been able to produce an error message in the form of:

error: argument labels '(foo:)' do not match any available overloads
    return M.V(foo: "hello")
@slavapestov
Copy link
Member

#15294

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants