IDE: Fire
Version: 9.0.97.2071, 9.1.100.2076 (was originally discovered in 8.4 beta 2 month ago)
Target: Java
Description:
For the Coordinate defined as:
public struct Coordinate<T: Comparable> {
/*! primarily designated to store longitude in degrees */
public var x: T
/*! primarily designated to store latitude in degrees */
public var y: T
public init(x: T, y: T){
self.x = x
self.y = y
}
public static func <(lhs: Coordinate<T>, rhs: Coordinate<T>) -> Bool{
//this compiles
return Comparable.op_LessThan(lhs.x, rhs.x) && Comparable.op_LessThan(lhs.y, rhs.y)
//this doesn't
//return lhs.x < rhs.x && lhs.y < rhs.y
}
}
both lhs and rhs are generic types with Comparable constraint. When trying to use operators on T itself, compilation will fail with: error E64: Type mismatch, cannot find operator to evaluate "T" < "T"
, however when actually calling the operator’s Java underlying method, it works as charm. It feels like that compiler is unaware of operator static method that are implemented on type T that implements comparable.