diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index a7e4fed2038..077785c16b6 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -1679,7 +1679,7 @@ namespace { // \endcode // // Here `P.foo` would be replaced with `S.foo` - if (!isExistentialMetatype && baseTy->is() && + if (!isExistentialMetatype && baseTy->isConstraintType() && member->isStatic()) { auto selfParam = overload.adjustedOpenedFullType->castTo()->getParams()[0]; diff --git a/test/Constraints/issue-60552.swift b/test/Constraints/issue-60552.swift new file mode 100644 index 00000000000..683dcfd55bb --- /dev/null +++ b/test/Constraints/issue-60552.swift @@ -0,0 +1,31 @@ +// RUN: %target-swift-emit-silgen %s + +// rdar://150858005 +protocol P {} +protocol Q {} + +struct MyP: P, Q {} + +extension P where Self == MyP { + static var myP: Self { return MyP() } +} + +func test() { + let _: any P & Q = .myP +} + +// rdar://148708774 +protocol Wrapper { + associatedtype Wrapped +} +struct IntWrapper: Wrapper { + typealias Wrapped = Int +} + +extension Wrapper where Self == IntWrapper { + static var int: Self { fatalError() } +} + +let crashes: any Wrapper = .int +let ok1: some Wrapper = .int +let ok2: any Wrapper = .int