mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In some cases, such as when pushing a collection conversion down to per-element conversions, we'll coerce a subtype metatype to AnyObject, as in:
```
func f(_: [AnyObject]) {}
f([NSString.self, NSObject.self]) // Type checks as [NSObject.Type] converted to [AnyObject]
```
and only record the restriction kinds used in the indirect steps NSString -> NSObject and NSObject.Type -> AnyObject without recording the jump from NSString.Type to AnyObject. coerceToType ought to apply this subtyping rule even without such a hint, though, since the restriction kind is intended only as an optimization. Fixes rdar://problem/42666956 .
20 lines
407 B
Swift
20 lines
407 B
Swift
// RUN: %target-typecheck-verify-swift %clang-importer-sdk
|
|
// RUN: %target-swift-emit-silgen(mock-sdk: %clang-importer-sdk) -verify %s
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
|
|
func f(_: [AnyObject]) {}
|
|
func g(_: [Protocol]) {}
|
|
|
|
f([NSString.self, NSObject.self])
|
|
|
|
@objc protocol P: AnyObject {}
|
|
@objc protocol Q: AnyObject {}
|
|
|
|
func foo(p: P.Type, pq: (P & Q).Type) {
|
|
f([p, pq])
|
|
}
|
|
|
|
g([P.self, Q.self])
|