Re: [swift-users] How to resolve "type(of: instance)" being shadowed by "instance.type"?

2017-09-22 Thread Glen Huang via swift-users
Ah, how come I never thought about trying that!? Thanks! Regards, Glen > On 23 Sep 2017, at 1:10 PM, Slava Pestov wrote: > > >> On Sep 22, 2017, at 10:10 PM, Glen Huang via swift-users >> wrote: >> >> I have a class like this: >> >> class File { >> type: FileType >> url: URL >> func fe

Re: [swift-users] How to resolve "type(of: instance)" being shadowed by "instance.type"?

2017-09-22 Thread Slava Pestov via swift-users
> On Sep 22, 2017, at 10:10 PM, Glen Huang via swift-users > wrote: > > I have a class like this: > > class File { > type: FileType > url: URL > func fetch(from server: Server) { > type(of: server).get(from: url) > } > } > > However, it fails to compile with "Cannot call value o

[swift-users] How to resolve "type(of: instance)" being shadowed by "instance.type"?

2017-09-22 Thread Glen Huang via swift-users
I have a class like this: class File { type: FileType url: URL func fetch(from server: Server) { type(of: server).get(from: url) } } However, it fails to compile with "Cannot call value of non-function type ‘File’” inside the body of fetch(from:). I believe the reason is that

Re: [swift-users] range(of:options:range:locale:) with partial ranges

2017-09-22 Thread Ben Cohen via swift-users
In order to be able to use pos… this function would need to be converted from it’s current signature (that takes a concrete Range) to be generic over any RangeExpression.In this case of this method, the range is optional – and in case of nil (which is the default) there would be insufficient con

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Shawn Erickson via swift-users
The bug is about the compiler reporting a compile error for a function that purposely is designed to allow for overflow and handling of said overflow. It should be allowed to be used in all scopes in code. It seems like the compiler is able to reason and prove overflow will happen in certain code s

[swift-users] Swift Version Conditionals in Objective-C?

2017-09-22 Thread Jon Shier via swift-users
In moving a hybrid project from Swift 3 to 4, I’ve run into some issues from my Objective-C code. I’ve been able to conditionalize my Swift code for both versions pretty easily, but there are APIs imported from Objective-C that need to change definition for Swift 4. Is there anyway, in p

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Claude Pommerell via swift-users
This is not a bug. The error reports correctly that -Int.min cannot be represented in the Int type. This holds true for all implementations of fixed-size signed integers in Swift and most languages. In fact, Int.min is defined as Int.min = -Int.max-1. The reason is that almost all fixed-sized i

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Martin R via swift-users
Filed as https://bugs.swift.org/browse/SR-5964 Martin > On 22. Sep 2017, at 12:11, Alex Blewitt wrote: > > Hmm... probably worth filing a bug at https://bugs.swift.org > then with the below test case. > > Alex > >> On 22 Sep

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Alex Blewitt via swift-users
Hmm... probably worth filing a bug at https://bugs.swift.org then with the below test case. Alex > On 22 Sep 2017, at 10:14, Martin R wrote: > > But the purpose of > > func dividedReportingOverflow(by other: Int > ) -> (partialValue: Int > , overflow: Bool >

[swift-users] Threads and weak references

2017-09-22 Thread Howard Lovatt via swift-users
Hi, I was using a weak reference in a concurrent application and and the main thread wasn't seeing an update to a class's property made by another thread. If I replaced the weak reference with a closure, the problem went away. Is there any documentation that describes this behaviour? Thanks in a

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Martin R via swift-users
But the purpose of func dividedReportingOverflow(by other: Int ) -> (partialValue: Int , overflow: Bool ) is to report an overflow in the return value. And actually this compiles and runs in Xcode 9 if the code is on top-level in main.m: let minusOne = -1 let r1 = Int.min.divide

Re: [swift-users] Where to report this bug?

2017-09-22 Thread Alex Blewitt via swift-users
Int.min is the smallest negative value, and Int.max is the largest positive value (that fits in an Int). However, the absolute value of Int.min is larger than the absolute value of Int.max. So you can't convert Int.min into -Int.min because it's larger than Int.max. In other words, this is expe