mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
multiple times, as well as teaching the name lookup mechanism that it's similarly rude to report ambiguous results because it searched the same import twice. Fixes <rdar://problem/11287213>. Yes, this is a bit of an ugly hack. Swift SVN r1610
20 lines
538 B
Swift
20 lines
538 B
Swift
// RUN: %swift -I %S/.. %s -verify
|
|
|
|
import swift
|
|
|
|
struct Complex {
|
|
Real : Double,
|
|
Imaginary : Double
|
|
func magnitude() -> Double {
|
|
return Real * Real + Imaginary * Imaginary
|
|
}
|
|
}
|
|
|
|
func [infix_left=200] * (lhs : Complex, rhs : Complex) -> Complex {
|
|
return Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary,
|
|
lhs.Real * rhs.Imaginary + lhs.Imaginary * rhs.Real)
|
|
}
|
|
func [infix_left=190] + (lhs: Complex, rhs: Complex) -> Complex {
|
|
return Complex(lhs.Real + rhs.Real, lhs.Imaginary + rhs.Imaginary)
|
|
}
|