Silver: Double properties are mis-implemented as functions

IDE: Fire
Version: 8.3
Description:

var x = (1.0).isNaN;
var y = (1.0).isFinite;
// etc

Expected Behavior:

Compiles (see https://developer.apple.com/reference/swift/floatingpoint)

Actual Behavior:

error E513: Parenthesis are required to call method isNaN()
error E513: Parenthesis are required to call method isFinite()

Steps:

hmm. what platform is this? i don’t see these defined by us as all:

var x = (1.0).isNaN // E44 No member "isNaN" on type "Double"
var y = (1.0).isFinite // E44 No member "isFinite" on type "Double"

Looks like you are using the Java methods on java.lang.Double:

public final class java.lang.Double : Number, Comparable<Double> { 
        public func toString() -> String!
        public func toString() -> String!
        public func toHexString() -> String!
        public func valueOf() -> Double!
        public static func valueOf(_ arg1: String!) -> Double!
        public static func parseDouble(_ arg1: String!) -> Double
        public func isNaN() -> Boolean
        public func isInfinite() -> Boolean
        public func isFinite() -> Boolean
1 Like

I see. How would I keep that from happening? Or is that an automatic interpretation for swift doubles?

that’s just the way it is, for now. remember that silver. brings the LANGUAGE to java, not the cocoa class libraries. the types you work with are the java and android types, not the cocoa types.

Ah. That may prove interesting for our application. :slight_smile:

Is this limited to the primitive types or are there other examples of implicit mapping to Java types?

ALL types you see in Silver/Java are Java types.