Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-21 Thread John Spurlock via swift-users
Nope, that doesn't work, try it yourself. I tried that, any many more variations, before posting the minimal repro example here. On Thu, Jul 21, 2016 at 5:46 PM, Jordan Rose wrote: > I’m a bit late here, but I don’t see why this is necessary. John overrode > 'encode(_:

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-21 Thread Tony Parker via swift-users
It’s because two separate methods in ObjC are apparently mapped to the exact same Swift signature on import. - Tony > On Jul 21, 2016, at 2:46 PM, Jordan Rose wrote: > > I’m a bit late here, but I don’t see why this is necessary. John overrode > 'encode(_: Int, forKey:

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-21 Thread Jordan Rose via swift-users
I’m a bit late here, but I don’t see why this is necessary. John overrode 'encode(_: Int, forKey: String)’ instead of ‘encode(_: Int32, forKey: String)’. Sure, overloading makes this kind of mistake harder to spot, especially when the run-time error comes from Objective-C, but it’s hardly

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-21 Thread Tony Parker via swift-users
FYI: https://github.com/apple/swift/pull/3663 - Tony > On Jul 20, 2016, at 12:10 PM, Tony Parker via swift-users > wrote: > >> >> On Jul 20, 2016, at 5:17 AM, John Spurlock >

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-20 Thread Tony Parker via swift-users
> On Jul 20, 2016, at 5:17 AM, John Spurlock wrote: > > 1. Since encoding/decoding various types is the principal domain of this > type, it seems ok to be overly clear in the method names here. > Agreed; I’m trying out a few approaches to see what works best. > 2.

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-20 Thread John Spurlock via swift-users
1. Since encoding/decoding various types is the principal domain of this type, it seems ok to be overly clear in the method names here. 2. Is there a way to systematically look for other types that may also have this problem lurking with ints or other similar overload groups? On Tue, Jul 19,

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-19 Thread Tony Parker via swift-users
I thought of the exact same name, but I'm not enthusiastic about the inconsistency this creates with all of the other decode methods on NSCoder. I'm discussing with a few people to decide what to do next. - Tony > On Jul 19, 2016, at 6:32 PM, Brent Royal-Gordon >

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-19 Thread Tony Parker via swift-users
Hi John, Thanks for filing the bug. The root cause of the issue is that the importer would turn the following methods into the same name: - (void)encodeInt:(int)x forKey:(NSString *)k; - (void)encodeInt32:(uint32_t)x forKey:(NSString *)k; Plus, there is the added confusion that this method:

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-19 Thread Brent Royal-Gordon via swift-users
> On Jul 19, 2016, at 8:20 AM, John Spurlock wrote: > > Is there anything I can do in the meantime as a swift-only workaround to fix > my custom NSCoder? Horrible possibility: `class_addMethod()` *is* available from Swift. You might be able to do some old-fashioned

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-19 Thread John Spurlock via swift-users
Ok, filed a new bug for the encodeInt:forKey issue: rdar://problem/27425997 Ensured it reproduces in xcode beta 3, swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33) Is there anything I can do in the meantime as a swift-only workaround to fix my custom NSCoder? Thanks, - john On Mon, Jul

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Tony Parker via swift-users
We renamed some of these methods for Swift 3 in an attempt to remove some of the confusion surrounding which of these did what - they were really named for C types and not Swift ones. encodeInt:forKey: and decodeInt:forKey: are the two missing ones, since they were easily confused with the

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Brent Royal-Gordon via swift-users
> Hi Tony - when I add that attribute, I get an error at compile-time: > Objective-C method has a different selector from the method it overrides > ('encodeInt:forKey:' vs. 'encodeInteger:forKey:') > > If I update to encodeInteger:forKey as the fix describes, it compiles, but > I'm getting the

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread John Spurlock via swift-users
Hi Tony - when I add that attribute, I get an error at compile-time: Objective-C method has a different selector from the method it overrides ('encodeInt:forKey:' vs. 'encodeInteger:forKey:') If I update to encodeInteger:forKey as the fix describes, it compiles, but I'm getting the same original

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Tony Parker via swift-users
Probably, but there could be a compiler bug or importer bug lurking here. - Tony > On Jul 18, 2016, at 5:29 PM, Jacob Bandes-Storch wrote: > > Shouldn't that be implicit, since the function is `override`? > > On Mon, Jul 18, 2016 at 5:25 PM, Tony Parker via swift-users >

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Jacob Bandes-Storch via swift-users
Shouldn't that be implicit, since the function is `override`? On Mon, Jul 18, 2016 at 5:25 PM, Tony Parker via swift-users < swift-users@swift.org> wrote: > Hi John, > > Can you try this? > > @objc(encodeInt:forKey:) > override func encode(_ intv: Int, forKey key: String) { >

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Tony Parker via swift-users
Hi John, Can you try this? @objc(encodeInt:forKey:) override func encode(_ intv: Int, forKey key: String) { print("\(key) \(intv)") // never called } - Tony > On Jul 18, 2016, at 12:11 AM, John Spurlock via swift-users > wrote: > > Minimal repro case

[swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread John Spurlock via swift-users
Minimal repro case below. I'm creating a custom NSCoder, but the "encodeInt:forKey" call is not dispatched properly to my overridden method when encoding an NSCalendar instance. What am I missing here? Without source code for any of this, I'm at a dead end. Thanks, - john