Xcode 7.1b2 (7B75): [Swift] CustomStringConvertible doesn't work when converting to String if compiling with Whole Module Optimization

Originator:janoschhildebrand
Number:rdar://22825770 Date Originated:23-Sep-2015
Status:Closed Resolved:Xcode 7.1b3
Product:Developer Tools Product Version:Xcode 7.1b2 (7B75)
Classification:Other Bug Reproducible:Always
 
Summary:
CustomStringConvertible (and CustomDebugStringConvertible) conformance isn't used properly when converting a variable to a String, if Whole Module Optimization is enabled.

The following example code demonstrates this issue:

struct Test: CustomStringConvertible {
    var description: String {
        return "This is a custom description"
    }
}


let t = Test()
print(t)

let s = String(t)
print(s)

// Workaround
print(t.description)


A project demonstrating this issue is attached.

Steps to Reproduce:
1. Download the attached project
2. Build & Run

Expected Results:
The program should print the following:

This is a custom description
This is a custom description
This is a custom description

Actual Results:
This is the actual result:

Test()
Test()
This is a custom description

Version:
Xcode 7.1b2 (7B75)
Apple Swift version 2.1 (swiftlang-700.1.100.4 clang-700.1.75)
OSX 10.11 (15A282b)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!