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-5497] Incorrect dynamic dispatch behaviour for class overridden across modules when using whole module optimization. #48069

Closed
swift-ci opened this issue Jul 18, 2017 · 1 comment
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-5497
Radar None
Original Reporter derekblr (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode Version 8.3.3 (8E3004b) , Swift 3

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

md5: 2d63037afdd34c62be4ebd4ea56801c8

duplicates:

  • SR-5499 Incorrect dynamic dispatch behaviour for nested class overridden across modules when using whole module optimization.

Issue Description:

Suppose in an external module we have these defs:

public struct Woof {
    open class Qux {
        open var name: String? {
            return nil
        }
        public func printName() {
            print(name ?? "no name")
        }
        public init() {}
    }
}

And then in the main module we have this:

class Foo: Woof.Qux {
    override var name: String {
        return "zorg"
    }    
}

let test = Foo()
test.printName()

Then if run with a release build config, we get "no name".
We can make it print "zorg" using any of the following changes:

Turn off "whole module optimization" for the external module.
Make Qux a non-nested type by moving it out of Woof.
Put all the code in the same module.

@belkadan
Copy link
Contributor

Looks like this got filed twice by accident?

@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