mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSOptimizer] test: Add test case for issue #85020
Overload resolution picks wrong initializer for some metatype arguments https://github.com/swiftlang/swift/issues/85020
This commit is contained in:
33
test/Interpreter/issue-85020.swift
Normal file
33
test/Interpreter/issue-85020.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
// RUN: %target-run-simple-swift | %FileCheck %s
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/85020
|
||||
|
||||
struct Store {
|
||||
let theType: Any.Type
|
||||
|
||||
init(of theType: Any.Type) {
|
||||
print("init from TYPE: \(theType)")
|
||||
self.theType = theType
|
||||
}
|
||||
|
||||
init(of instance: Any) {
|
||||
print("init from VALUE: \(instance)")
|
||||
self.init(of: type(of: instance))
|
||||
}
|
||||
}
|
||||
|
||||
let a: (any Numeric)? = 42
|
||||
print("a: \(type(of: a))")
|
||||
// CHECK: a: Optional<Numeric>
|
||||
|
||||
let storeA = Store(of: a!)
|
||||
// CHECK-NEXT: init from VALUE: 42
|
||||
// CHECK-NEXT: init from TYPE: Int
|
||||
|
||||
let b: (any Numeric.Type)? = type(of: 42)
|
||||
print("b: \(type(of: b))")
|
||||
// CHECK-NEXT: b: Optional<Numeric.Type>
|
||||
|
||||
let storeB = Store(of: b!)
|
||||
// CHECK-NEXT: init from TYPE: Int
|
||||
|
||||
Reference in New Issue
Block a user