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-7214] TYPE MISMATCH IN ARGUMENT 0 OF APPLY AT expression #49762

Closed
swift-ci opened this issue Mar 16, 2018 · 4 comments
Closed

[SR-7214] TYPE MISMATCH IN ARGUMENT 0 OF APPLY AT expression #49762

swift-ci opened this issue Mar 16, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7214
Radar None
Original Reporter moaible (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

LLVM 6073168ec6, Clang fe4240de1a, Swift 7730dd3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: e895c220c7b3c633b397aed4ab1416f3

duplicates:

  • SR-6000 Let protocols inherit from class types

Issue Description:

This code crashes.

class Object {}

protocol SomeChild where Self : Object {
    func doSomething()
}

extension SomeChild {
    func doSomething() {
        print(self)
    }
}

class ChildObject: Object, SomeChild {}

class ParentObject: Object {
    var child: SomeChild = ChildObject()
}

let parent = ParentObject()
parent.child.doSomething()

But this code works.

class Object {}

protocol SomeChild {
    func doSomething()
}

extension SomeChild where Self : Object {
    func doSomething() {
        print(self)
    }
}

class ChildObject: Object, SomeChild {}

class ParentObject: Object {
    var child: SomeChild = ChildObject()
}

let parent = ParentObject()
parent.child.doSomething()
@belkadan
Copy link
Contributor

@slavapestov, another of these protocol-constrained-to-class ones.

TYPE MISMATCH IN ARGUMENT 0 OF APPLY AT expression at [<stdin>:20:8 - line:20:26] RangeText="child.doSomething()"
  argument value:   %12 = open_existential_addr immutable_access %9 : $*SomeChild to $*@opened("5F4ABE1A-2933-11E8-BF3A-E0ACCB6CE3C2") SomeChild // user: %13
  parameter type: $@opened("5F4ABE1A-2933-11E8-BF3A-E0ACCB6CE3C2") SomeChild

Who's tracking these?

@hamishknight
Copy link
Collaborator

We also have https://bugs.swift.org/browse/SR-6816 & https://bugs.swift.org/browse/SR-7068 for this bug, should we close them as dupes of this one if we're going to use this one to track progress?

@slavapestov
Copy link
Member

For now let's keep them separate. When I get around to working on this I'll go through the bugs and verify that they are indeed dupes (but you're right that they look very similar).

@slavapestov
Copy link
Member

Also, you guys are way too clever. You'll notice that we don't allow classes to appear in protocol inheritance clauses yet, because this feature was not implemented. But we didn't realize that when we implemented protocol where clauses, you could just as easily write 'where Self : SomeClass' instead. So when this is all fixed, both forms will be equivalent and (hopefully) work.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

5 participants