CustomReflectable doesn't work if it's implemented as an extension

Swift CustomReflectable doesn't work if it's been implemented in separated file in separated static library.

//  BBB.swift
public struct BBB {
    public var xcv = 344
    public init() {}
}

//  BBB.mirror.swift
extension BBB: CustomReflectable {}
public extension BBB {
    var customMirror: Mirror {
        return Mirror(
            self,
            children: [
                "xxx": 342,
                "www": 999])
    }
}

This doesn't work in both of Xcode 10.2.1 and Xcode 11 Beta 2.

Moving protocol conformation to type body make it work again.

public struct BBB: CustomReflectable {
    public var xcv = 344
    public init() {}
}
public extension BBB {
    var customMirror: Mirror {
        return Mirror(
            self,
            children: [
                "xxx": 342,
                "www": 999])
    }
}

Here's a project to reproduce issue.

Currently, this issue blocks me to define custom reflections for existing types for existing libraries...

It seems to be a bug. Am I the only person with this issue? Or is this a designed behavior? If it is, it should be noted on code documentation.

Terms of Service

Privacy Policy

Cookie Policy