When using build tools 14.3 everything works, but when using 15.1 the following piece of code fails to compile when BUILD_LIBRARY_FOR_DISTRIBUTION is set to YES.

public protocol Test<PrimaryType> {
    associatedtype PrimaryType

    func give() -> PrimaryType
}

public typealias Concrete = Test<Int> & AnyObject

public protocol Factory {
    func concrete() -> any Concrete
}

It looks like a bug was introduced in the new build tools version.

The output error is:

/Users/{redacted}/Library/Developer/Xcode/DerivedData/TestPat-bhxphcvnfxvnqqawqjiikabafbhb/Build/Intermediates.noindex/TestPat.build/Release-iphoneos/PatTest.build/Objects-normal/arm64/PatTest.swiftinterface:21:26: error: non-protocol, non-class type 'Test<Int>' cannot be used within a protocol-constrained type
  func concrete() -> any PatTest.Test<Swift.Int> & Swift.AnyObject
                         ^
/Users/{redacted}/Library/Developer/Xcode/DerivedData/TestPat-bhxphcvnfxvnqqawqjiikabafbhb/Build/Intermediates.noindex/TestPat.build/Release-iphoneos/PatTest.build/Objects-normal/arm64/PatTest.swiftinterface:1:1: error: failed to verify module interface of 'PatTest' due to the errors above; the textual interface may be broken by project issues or a compiler bug
// swift-interface-format-version: 1.0
^

** BUILD FAILED **

excerpt:

error: non-protocol, non-class type 'Test<Int>'
cannot be used within a protocol-constrained type
  func concrete() -> any PatTest.Test<Swift.Int> & Swift.AnyObject
                         ^

I would expect this should compile with no issues.