Files
swift-mirror/test/Constraints/concrete-overload-required.swift
Mark Lacey 4984a4bb1b Add a test involving multiple literal conformances.
For this to successfully typecheck, we need to ensure that we do not
bail out too early in considering options.
2018-09-30 06:26:45 -07:00

47 lines
951 B
Swift

// RUN: %target-typecheck-verify-swift
infix operator +++ : AdditionPrecedence
infix operator *** : MultiplicationPrecedence
protocol P {
static func +++ (lhs: Self, rhs: Self) -> Self
}
extension P {
static func +++ (lhs: Self, rhs: Self) -> Self {
return lhs
}
}
protocol Q {
static func *** (lhs: Self, rhs: Self) -> Self
}
struct Y : Q {
static func *** (lhs: Y, rhs: Y) -> Y {
return rhs
}
}
struct X : P, ExpressibleByIntegerLiteral, ExpressibleByStringLiteral
{
typealias IntegerLiteralType = Int
public init(integerLiteral value: IntegerLiteralType) {}
typealias StringLiteralType = String
public init(stringLiteral value: StringLiteralType) {}
}
// This overload is required in order to be able to typecheck the
// expression at the bottom.
extension X : Q {
static func *** (lhs: X, rhs: X) -> X {
return rhs
}
}
extension Int : P {}
extension String : P {}
let _ = 1 +++ "hi" +++ 3 *** 4 +++ 5