Skip to content

Commit d350bc7

Browse files
committed
[CSOptimizer] test: Add test case for issue #85020
Overload resolution picks wrong initializer for some metatype arguments #85020
1 parent a1b41ac commit d350bc7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/Interpreter/issue-85020.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-run-simple-swift | %FileCheck %s
2+
3+
// https://github.com/swiftlang/swift/issues/85020
4+
5+
struct Store {
6+
let theType: Any.Type
7+
8+
init(of theType: Any.Type) {
9+
print("init from TYPE: \(theType)")
10+
self.theType = theType
11+
}
12+
13+
init(of instance: Any) {
14+
print("init from VALUE: \(instance)")
15+
self.init(of: type(of: instance))
16+
}
17+
}
18+
19+
let a: (any Numeric)? = 42
20+
print("a: \(type(of: a))")
21+
// CHECK: a: Optional<Numeric>
22+
23+
let storeA = Store(of: a!)
24+
// CHECK-NEXT: init from VALUE: 42
25+
// CHECK-NEXT: init from TYPE: Int
26+
27+
let b: (any Numeric.Type)? = type(of: 42)
28+
print("b: \(type(of: b))")
29+
// CHECK-NEXT: b: Optional<Numeric.Type>
30+
31+
let storeB = Store(of: b!)
32+
// CHECK-NEXT: init from TYPE: Int
33+

0 commit comments

Comments
 (0)