Open swift-ci opened 7 years ago
Yeah, it would be reasonable to have to write this as is CNLabeledValue
, without the generic parameters, to underscore the fact that it can't check for that. I'm not sure what we'd do for as?
though, where it needs a final type.
A related issue: you can't declare a CNLabeledValue variable. If you try this:
var val : CNLabeledValue?
you're told it's a generic and needs an explicit parameterized type. But what type, in general, can you supply? The correct umbrella type, according to the Contacts framework, is `NSCopying & NSSecureCoding`, and FixIt actually suggests that, correctly. But if you do in fact insert it, you get another error:
var val : CNLabeledValue<NSCopying & NSSecureCoding>?
You are told: "'NSCopying & NSSecureCoding' cannot be used as a type conforming to protocol 'NSSecureCoding' because 'NSSecureCoding' has static requirements."
Environment
Swift 3Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, TypeChecker | |Assignee | None | |Priority | Medium | md5: c52eb61cc6462c3025b48a3c62ba4312Issue Description:
I have this code:
And it will print allways "true", but it should realy print "flase", because o is "CNLabeledValue\<CNInstantMessageAddress>" and not "CNLabeledValue\<CNPhoneNumber>"
I put this on the dev forum and get this respond:
These types are imported from Objective-C and Objective-C’s lightweight generic system is only available at compile time, not runtime. From the Objective-C runtime’s perspective, CNLabeledValue\<CNInstantMessageAddress> and CNLabeledValue\<CNPhoneNumber> are the same type, that is, CNLabeledValue.
https://forums.developer.apple.com/message/221273
I think the generic should be validated, or should generate a build error, or at least a warning, it cloud lead to weird bugs on the apps.