"Int is not convertible to IntegerLiteralConvertible"... Huh?

Xcode 7 Beta 4, the following code:


let view = myOutlineView.viewAtColumn(1, row: checkbox.tag, makeIfNecessary: false)
                                      ^


gives me an error: "'Int' is not convertible to 'IntegerLiteralConvertible'" at the first arguemnt.


Huh? The interface for viewAtColumn is:

func viewAtColumn(column: Int, row: Int, makeIfNecessary: Bool) -> NSView?


So, if I pass in non-literal values, no error:

let col = 1
let make = false
let view = myOutlineView.viewAtColumn(col, row: checkbox.tag, makeIfNecessary: make)


Am I missing something, or is this a bug in Swift/Xcode/NSOutlineView?

Answered by ChrisLattner in 32294022

This is a fairly classical example of when the type checker gets confused and emits a non-sensical diagnostic. This is one of the areas of focus to improve in Xcode 7, so if you run across examples like this, please file a radar with an (ideally small) example that shows it. Beta 4 has some improvements to these sorts of diagnostics, but more improvements are coming.


-Chris

I can't reproduce that error, ie the following short program compiles as expected in Xcode 7 beta 4:

import Cocoa
let myOutlineView = NSOutlineView()
let checkbox = NSButton()
let view = myOutlineView.viewAtColumn(1, row: checkbox.tag, makeIfNecessary: false)

With the first line of code you have shown (supplying myOutlineView & checkbox), I cannot get any error messages from my Xcode 7 beta 4.


Maybe some other parts of your code is affecting, like making something IntegerLiteralConvertible.

Sigh... and now the error has gone away... I can't reproduce it either. I'm going to pretend this never happened 😉

Thanks all.

Accepted Answer

This is a fairly classical example of when the type checker gets confused and emits a non-sensical diagnostic. This is one of the areas of focus to improve in Xcode 7, so if you run across examples like this, please file a radar with an (ideally small) example that shows it. Beta 4 has some improvements to these sorts of diagnostics, but more improvements are coming.


-Chris

Thanks Chris, glad I'm not going crazy 😉


I'll keep an eye out for things like this and get radars in when I can.

"Int is not convertible to IntegerLiteralConvertible"... Huh?
 
 
Q