Files
swift-mirror/test/Interpreter/complex.swift
Doug Gregor a04776044e Teach the import mechanism that it's rude to parse the same library
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
2012-04-24 22:36:17 +00:00

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)
}