Files
swift-mirror/test/Constraints/rdar42750089.swift
Pavel Yaskevich e117dd966c [Sema] SE-0213: Fix LinkedExprAnalyzer to not record types for literal init
Literal initialization via coercion makes current incorrect logic
slightly more eager still, which leads to more chained arithmetic
operator expressions to be recognized as "symmetric" and their type
variables merged.

Although literal init via coercion does provide more type information,
let's treat it as regular initializer calls and don't record the types.

Resolves: rdar://problem/42750089
2018-07-30 20:38:47 -07:00

75 lines
1.2 KiB
Swift

// RUN: %target-typecheck-verify-swift
protocol P : Equatable {
associatedtype T = String
}
struct S : Hashable {
var key: String
init(_ key: String) {
self.key = key
}
}
extension S : ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self.init(value)
}
}
extension S : _ExpressibleByStringInterpolation {
init(stringInterpolation strings: S...) {
self.key = "foo"
}
init<T>(stringInterpolationSegment expr: T) {
self.init(String(describing: expr))
}
}
extension S : P {}
struct ConcP<F: P, S: P> : P where F.T == S.T {
var lhs: F
var rhs: S
}
struct Z : P {
}
extension P {
func bar() -> Z { fatalError() }
static func +<T : P>(lhs: Self, rhs: T) -> ConcP<Self, T> {
return ConcP(lhs: lhs, rhs: rhs)
}
}
class Container<V> {
var value: V
init(_ value: V) {
self.value = value
}
}
struct A {
enum Value : CustomStringConvertible {
case foo, bar
var description: String {
switch self {
case .foo: return "foo"
case .bar: return "bar"
}
}
}
var value: Container<Value>
func foo() {
let value = self.value.value
_ = S("A") + S("\(value)").bar() + S("B") // Ok
}
}