# \[Pitch\] Fully eliminate implicit bridging conversions in Swift 3

**URL:** <https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256>\
**Category:** Pitches\
**Created:** [April 19, 2016, 3:21am UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256 "2016-04-19T03:21:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Pamer](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Joe\_Pamer](https://forums.swift.org/u/Joe_Pamer)\
**Post date:** [April 19, 2016, 3:21am UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/1 "2016-04-19T03:21:42Z")

</div>

Hi everyone,

Prior to Swift 1.2, conversions between bridged Swift value types and their associated Objective-C types could be implicitly inferred in both directions. For example, you could pass an NSString object to a function expecting a String value, and vice versa.

In time we found this model to be less than perfect for a variety of reasons:  
Allowing implicit conversions between types that lack a subtype relationship felt wrong in the context of our type system.  
Importing Foundation would lead to subtle changes in how seemingly simple bodies of code were type checked.  
The specific rules implemented by the compiler to support implicit bridging conversions were complex and ad-hoc.  
Looking at the Swift code that had been written up until 1.2, these kinds of implicit conversions did not appear terribly common. (And where they were present, it wasn’t clear if users actually knew they were taking place.)

In short, these conversions generally lead to a more confusing and unpredictable user model. So, for Swift 1.2, we sought to eliminate implicit bridging conversions entirely, and instead direct users to use explicit bridging casts in their place. (E.g., “nsStrObj as String”.)

Unfortunately, when it came time to roll out these changes, we noticed that some native Objective-C APIs were now more difficult to work with in Swift 1.2. Specifically, because global Objective-C NSString\* constants are imported into Swift as having type String, APIs that relied on string-constant lookups into dictionaries imported as [NSObject : AnyObject] failed to compile. E.g.

var s : NSAttributedString  
let SomeNSFontAttributeName : String // As per the importer.

let attrs = s.attributesAtIndex(0, effectiveRange:nil) // In Swift 2, ‘attrs’ has type [NSObject : AnyObject]  
let fontName = attrs[SomeNSFontAttributeName] // This will fail to compile without an implicit conversion from String to NSString.

For this reason, we decided to make a compromise. We would require explicit bridging casts when converting from a bridged Objective-C type to its associated Swift value type (E.g., NSString -\> String), but not the other way around. This would improve the status quo somewhat, and would also avoid breaking user code in a needless/painful fashion until we could get better API annotations in place.

With the introduction of Objective-C generics last year, along with all of the awesome improvements to API importing happening for Swift 3, I think it’s time that we take another look at completing this work. Taking a look back at last year’s “problematic” APIs, all of them now surface richer type information when imported into Swift 3. As a result, the remaining implicit bridging conversions now feel far less necessary, since Objective-C APIs are now more commonly exposed in terms of their appropriate bridged Swift value types. (For instance, in Swift 3, the above reference to attrs will import as [String : AnyObject].)

I propose that we fully eliminate implicit bridging conversions in Swift 3. This would mean that some users might have to introduce introduce a few more ‘as’ casts in their code, but we would remove another special case from Swift's type system and be able to further simplify the compiler. If anyone is curious and would like to take this model for a spin, I’ve pushed an experimental branch that implements this proposed change, inhibit-implicit-conversions.

Thoughts?

Thanks!  
- Joe

---

<div class="post-metadata">

**Author:** ![jtbandes](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jtbandes/32/463_2.png) [@jtbandes](https://forums.swift.org/u/jtbandes)\
**Post date:** [April 19, 2016, 5:08am UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/2 "2016-04-19T05:08:41Z")

</div>

Is it true that some CF APIs, such as these, are still imported as CFString  
instead of String?

> <https://github.com/apple/swift-3-api-guidelines-review/blob/swift-3/Platforms/OSX/CoreText/CTFontTraits.swift#L2-L9>

> **···**
>
> On Mon, Apr 18, 2016 at 8:21 PM, Joe Pamer via swift-evolution \< swift-evolution@swift.org\> wrote:
> 
> > Hi everyone,
> > 
> > Prior to Swift 1.2, conversions between bridged Swift value types and  
> > their associated Objective-C types could be implicitly inferred in both  
> > directions. For example, you could pass an NSString object to a function  
> > expecting a String value, and vice versa.
> > 
> > In time we found this model to be less than perfect for a variety of  
> > reasons:
> > 
> > &nbsp;&nbsp;&nbsp;- Allowing implicit conversions between types that lack a subtype  
> > &nbsp;&nbsp;&nbsp;relationship felt wrong in the context of our type system.  
> > &nbsp;&nbsp;&nbsp;- Importing Foundation would lead to subtle changes in how seemingly  
> > &nbsp;&nbsp;&nbsp;simple bodies of code were type checked.  
> > &nbsp;&nbsp;&nbsp;- The specific rules implemented by the compiler to support implicit  
> > &nbsp;&nbsp;&nbsp;bridging conversions were complex and ad-hoc.  
> > &nbsp;&nbsp;&nbsp;- Looking at the Swift code that had been written up until 1.2, these  
> > &nbsp;&nbsp;&nbsp;kinds of implicit conversions did not appear terribly common. (And where  
> > &nbsp;&nbsp;&nbsp;they \*were\* present, it wasn’t clear if users actually knew they were  
> > &nbsp;&nbsp;&nbsp;taking place.)
> > 
> > In short, these conversions generally lead to a more confusing and  
> > unpredictable user model. So, for Swift 1.2, we sought to eliminate  
> > implicit bridging conversions entirely, and instead direct users to use  
> > explicit bridging casts in their place. (E.g., “nsStrObj as String”.)
> > 
> > Unfortunately, when it came time to roll out these changes, we noticed  
> > that some native Objective-C APIs were now more difficult to work with in  
> > Swift 1.2. Specifically, because global Objective-C NSString\* constants  
> > are imported into Swift as having type String, APIs that relied on  
> > string-constant lookups into dictionaries imported as [NSObject :  
> > AnyObject] failed to compile. E.g.
> > 
> > var s : NSAttributedString  
> > let SomeNSFontAttributeName : String // As per the importer.
> > 
> > let attrs = s.attributesAtIndex(0, effectiveRange:nil) // In Swift 2,  
> > ‘attrs’ has type [NSObject : AnyObject]  
> > let fontName = attrs[SomeNSFontAttributeName] // This will fail to compile  
> > without an implicit conversion from String to NSString.
> > 
> > For this reason, we decided to make a compromise. We would require  
> > explicit bridging casts when converting from a bridged Objective-C type to  
> > its associated Swift value type (E.g., NSString -\> String), but not the  
> > other way around. This would improve the status quo somewhat, and would  
> > also avoid breaking user code in a needless/painful fashion until we could  
> > get better API annotations in place.
> > 
> > With the introduction of Objective-C generics last year, along with all of  
> > the awesome improvements to API importing happening for Swift 3, I think  
> > it’s time that we take another look at completing this work. Taking a look  
> > back at last year’s “problematic” APIs, all of them now surface richer type  
> > information when imported into Swift 3. As a result, the remaining implicit  
> > bridging conversions now feel far less necessary, since Objective-C APIs  
> > are now more commonly exposed in terms of their appropriate bridged Swift  
> > value types. (For instance, in Swift 3, the above reference to attrs will  
> > import as [String : AnyObject].)
> > 
> > I propose that we fully eliminate implicit bridging conversions in Swift  
> > 3. This would mean that some users might have to introduce introduce a few  
> > more ‘as’ casts in their code, but we would remove another special case  
> > from Swift's type system and be able to further simplify the compiler. If  
> > anyone is curious and would like to take this model for a spin, I’ve pushed  
> > an experimental branch that implements this proposed change,  
> > inhibit-implicit-conversions.
> > 
> > Thoughts?
> > 
> > Thanks!  
> > - Joe
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![gparker42](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gparker42/32/373_2.png) [@gparker42](https://forums.swift.org/u/gparker42)\
**Post date:** [April 19, 2016, 2:28pm UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/3 "2016-04-19T14:28:54Z")

</div>

What happens with string literals? Are they implicitly converted to NSString as necessary? Which of the following will be legal?

&nbsp;&nbsp;&nbsp;&nbsp;import Foundation  
&nbsp;&nbsp;&nbsp;&nbsp;func s(\_ str: String) { }  
&nbsp;&nbsp;&nbsp;&nbsp;func ns(\_ str: NSString) { }

&nbsp;&nbsp;&nbsp;&nbsp;let str: String = "foo"  
&nbsp;&nbsp;&nbsp;&nbsp;let nsstr: NSString = "foo"

&nbsp;&nbsp;&nbsp;&nbsp;NSLog("foo")  
&nbsp;&nbsp;&nbsp;&nbsp;NSLog(str)  
&nbsp;&nbsp;&nbsp;&nbsp;NSLog(nsstr)

&nbsp;&nbsp;&nbsp;&nbsp;s("foo")  
&nbsp;&nbsp;&nbsp;&nbsp;s(str)  
&nbsp;&nbsp;&nbsp;&nbsp;s(nsstr)

&nbsp;&nbsp;&nbsp;&nbsp;ns("foo")  
&nbsp;&nbsp;&nbsp;&nbsp;ns(str)  
&nbsp;&nbsp;&nbsp;&nbsp;ns(nsstr)

> **···**
>
> > On Apr 18, 2016, at 8:21 PM, Joe Pamer via swift-evolution \<swift-evolution@swift.org\> wrote:
> > 
> > I propose that we fully eliminate implicit bridging conversions in Swift 3. This would mean that some users might have to introduce introduce a few more ‘as’ casts in their code, but we would remove another special case from Swift's type system and be able to further simplify the compiler. If anyone is curious and would like to take this model for a spin, I’ve pushed an experimental branch that implements this proposed change, inhibit-implicit-conversions.
> 
> --  
> Greg Parker gparker@apple.com Runtime Wrangler

---

<div class="post-metadata">

**Author:** ![Haravikk3](https://avatars.discourse-cdn.com/v4/letter/h/df705f/32.png) [@Haravikk3](https://forums.swift.org/u/Haravikk3)\
**Post date:** [April 19, 2016, 12:42pm UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/4 "2016-04-19T12:42:59Z")

</div>

+1 from me; I’ve been dealing with a lot of conversion and yet it’s still pretty confusing largely because of the implicit conversions, it also goes against (pure) Swift’s elegant yet strictly typed checking system.

> **···**
>
> > On 19 Apr 2016, at 04:21, Joe Pamer via swift-evolution \<swift-evolution@swift.org\> wrote:
> > 
> > Hi everyone,
> > 
> > Prior to Swift 1.2, conversions between bridged Swift value types and their associated Objective-C types could be implicitly inferred in both directions. For example, you could pass an NSString object to a function expecting a String value, and vice versa.
> > 
> > In time we found this model to be less than perfect for a variety of reasons:  
> > Allowing implicit conversions between types that lack a subtype relationship felt wrong in the context of our type system.  
> > Importing Foundation would lead to subtle changes in how seemingly simple bodies of code were type checked.  
> > The specific rules implemented by the compiler to support implicit bridging conversions were complex and ad-hoc.  
> > Looking at the Swift code that had been written up until 1.2, these kinds of implicit conversions did not appear terribly common. (And where they were present, it wasn’t clear if users actually knew they were taking place.)
> > 
> > In short, these conversions generally lead to a more confusing and unpredictable user model. So, for Swift 1.2, we sought to eliminate implicit bridging conversions entirely, and instead direct users to use explicit bridging casts in their place. (E.g., “nsStrObj as String”.)
> > 
> > Unfortunately, when it came time to roll out these changes, we noticed that some native Objective-C APIs were now more difficult to work with in Swift 1.2. Specifically, because global Objective-C NSString\* constants are imported into Swift as having type String, APIs that relied on string-constant lookups into dictionaries imported as [NSObject : AnyObject] failed to compile. E.g.
> > 
> > var s : NSAttributedString  
> > let SomeNSFontAttributeName : String // As per the importer.
> > 
> > let attrs = s.attributesAtIndex(0, effectiveRange:nil) // In Swift 2, ‘attrs’ has type [NSObject : AnyObject]  
> > let fontName = attrs[SomeNSFontAttributeName] // This will fail to compile without an implicit conversion from String to NSString.
> > 
> > For this reason, we decided to make a compromise. We would require explicit bridging casts when converting from a bridged Objective-C type to its associated Swift value type (E.g., NSString -\> String), but not the other way around. This would improve the status quo somewhat, and would also avoid breaking user code in a needless/painful fashion until we could get better API annotations in place.
> > 
> > With the introduction of Objective-C generics last year, along with all of the awesome improvements to API importing happening for Swift 3, I think it’s time that we take another look at completing this work. Taking a look back at last year’s “problematic” APIs, all of them now surface richer type information when imported into Swift 3. As a result, the remaining implicit bridging conversions now feel far less necessary, since Objective-C APIs are now more commonly exposed in terms of their appropriate bridged Swift value types. (For instance, in Swift 3, the above reference to attrs will import as [String : AnyObject].)
> > 
> > I propose that we fully eliminate implicit bridging conversions in Swift 3. This would mean that some users might have to introduce introduce a few more ‘as’ casts in their code, but we would remove another special case from Swift's type system and be able to further simplify the compiler. If anyone is curious and would like to take this model for a spin, I’ve pushed an experimental branch that implements this proposed change, inhibit-implicit-conversions.
> > 
> > Thoughts?
> > 
> > Thanks!  
> > - Joe  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![VladimirS](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@VladimirS](https://forums.swift.org/u/VladimirS)\
**Post date:** [April 19, 2016, 12:23pm UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/5 "2016-04-19T12:23:06Z")

</div>

I fully support this proposal. IMO we should be moving forward and improve Swift, separate it from ObjC and explicitly bridge when needed.

> **···**
>
> On 19.04.2016 6:21, Joe Pamer via swift-evolution wrote:
> 
> > Hi everyone,
> > 
> > Prior to Swift 1.2, conversions between bridged Swift value types and their  
> > associated Objective-C types could be implicitly inferred in both  
> > directions. For example, you could pass an NSString object to a function  
> > expecting a String value, and vice versa.
> > 
> > In time we found this model to be less than perfect for a variety of reasons:
> > 
> > &nbsp;&nbsp;\* Allowing implicit conversions between types that lack a subtype  
> > &nbsp;&nbsp;&nbsp;&nbsp;relationship felt wrong in the context of our type system.  
> > &nbsp;&nbsp;\* Importing Foundation would lead to subtle changes in how seemingly  
> > &nbsp;&nbsp;&nbsp;&nbsp;simple bodies of code were type checked.  
> > &nbsp;&nbsp;\* The specific rules implemented by the compiler to support implicit  
> > &nbsp;&nbsp;&nbsp;&nbsp;bridging conversions were complex and ad-hoc.  
> > &nbsp;&nbsp;\* Looking at the Swift code that had been written up until 1.2, these  
> > &nbsp;&nbsp;&nbsp;&nbsp;kinds of implicit conversions did not appear terribly common. (And  
> > &nbsp;&nbsp;&nbsp;&nbsp;where they /were/ present, it wasn’t clear if users actually knew they  
> > &nbsp;&nbsp;&nbsp;&nbsp;were taking place.)
> > 
> > In short, these conversions generally lead to a more confusing and  
> > unpredictable user model. So, for Swift 1.2, we sought to eliminate  
> > implicit bridging conversions entirely, and instead direct users to use  
> > explicit bridging casts in their place. (E.g., “nsStrObj as String”.)
> > 
> > Unfortunately, when it came time to roll out these changes, we noticed that  
> > some native Objective-C APIs were now more difficult to work with in Swift  
> > 1.2. Specifically, because global Objective-C NSString\* constants are  
> > imported into Swift as having type String, APIs that relied on  
> > string-constant lookups into dictionaries imported as [NSObject :  
> > AnyObject] failed to compile. E.g.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;var s : NSAttributedString  
> > &nbsp;&nbsp;&nbsp;&nbsp;let SomeNSFontAttributeName : String // As per the importer.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;let attrs = s.attributesAtIndex(0, effectiveRange:nil) // In Swift 2,  
> > &nbsp;&nbsp;&nbsp;&nbsp;‘attrs’ has type [NSObject : AnyObject]  
> > &nbsp;&nbsp;&nbsp;&nbsp;let fontName = attrs[SomeNSFontAttributeName] // This will fail to  
> > &nbsp;&nbsp;&nbsp;&nbsp;compile without an implicit conversion from String to NSString.
> > 
> > For this reason, we decided to make a compromise. We would require explicit  
> > bridging casts when converting from a bridged Objective-C type to its  
> > associated Swift value type (E.g., NSString -\> String), but not the other  
> > way around. This would improve the status quo somewhat, and would also  
> > avoid breaking user code in a needless/painful fashion until we could get  
> > better API annotations in place.
> > 
> > With the introduction of Objective-C generics last year, along with all of  
> > the awesome improvements to API importing happening for Swift 3, I think  
> > it’s time that we take another look at completing this work. Taking a look  
> > back at last year’s “problematic” APIs, all of them now surface richer type  
> > information when imported into Swift 3. As a result, the remaining implicit  
> > bridging conversions now feel far less necessary, since Objective-C APIs  
> > are now more commonly exposed in terms of their appropriate bridged Swift  
> > value types. (For instance, in Swift 3, the above reference to attrs will  
> > import as [String : AnyObject].)
> > 
> > I propose that we fully eliminate implicit bridging conversions in Swift 3.  
> > This would mean that some users might have to introduce introduce a few  
> > more ‘as’ casts in their code, but we would remove another special case  
> > from Swift's type system and be able to further simplify the compiler. If  
> > anyone is curious and would like to take this model for a spin, I’ve pushed  
> > an experimental branch that implements this proposed  
> > change, inhibit-implicit-conversions.
> > 
> > Thoughts?
> > 
> > Thanks!  
> > - Joe
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![griotspeak](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/griotspeak/32/1966_2.png) [@griotspeak](https://forums.swift.org/u/griotspeak)\
**Post date:** [April 19, 2016, 1:18pm UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/6 "2016-04-19T13:18:19Z")

</div>

+1 from me

> **···**
>
> On Tue, Apr 19, 2016 at 8:42 AM, Haravikk via swift-evolution \< swift-evolution@swift.org\> wrote:
> 
> > +1 from me; I’ve been dealing with a lot of conversion and yet it’s still  
> > pretty confusing largely because of the implicit conversions, it also goes  
> > against (pure) Swift’s elegant yet strictly typed checking system.
> > 
> > On 19 Apr 2016, at 04:21, Joe Pamer via swift-evolution \< \> swift-evolution@swift.org\> wrote:
> > 
> > Hi everyone,
> > 
> > Prior to Swift 1.2, conversions between bridged Swift value types and  
> > their associated Objective-C types could be implicitly inferred in both  
> > directions. For example, you could pass an NSString object to a function  
> > expecting a String value, and vice versa.
> > 
> > In time we found this model to be less than perfect for a variety of  
> > reasons:
> > 
> > &nbsp;&nbsp;&nbsp;- Allowing implicit conversions between types that lack a subtype  
> > &nbsp;&nbsp;&nbsp;relationship felt wrong in the context of our type system.  
> > &nbsp;&nbsp;&nbsp;- Importing Foundation would lead to subtle changes in how seemingly  
> > &nbsp;&nbsp;&nbsp;simple bodies of code were type checked.  
> > &nbsp;&nbsp;&nbsp;- The specific rules implemented by the compiler to support implicit  
> > &nbsp;&nbsp;&nbsp;bridging conversions were complex and ad-hoc.  
> > &nbsp;&nbsp;&nbsp;- Looking at the Swift code that had been written up until 1.2, these  
> > &nbsp;&nbsp;&nbsp;kinds of implicit conversions did not appear terribly common. (And where  
> > &nbsp;&nbsp;&nbsp;they \*were\* present, it wasn’t clear if users actually knew they were  
> > &nbsp;&nbsp;&nbsp;taking place.)
> > 
> > In short, these conversions generally lead to a more confusing and  
> > unpredictable user model. So, for Swift 1.2, we sought to eliminate  
> > implicit bridging conversions entirely, and instead direct users to use  
> > explicit bridging casts in their place. (E.g., “nsStrObj as String”.)
> > 
> > Unfortunately, when it came time to roll out these changes, we noticed  
> > that some native Objective-C APIs were now more difficult to work with in  
> > Swift 1.2. Specifically, because global Objective-C NSString\* constants  
> > are imported into Swift as having type String, APIs that relied on  
> > string-constant lookups into dictionaries imported as [NSObject :  
> > AnyObject] failed to compile. E.g.
> > 
> > var s : NSAttributedString  
> > let SomeNSFontAttributeName : String // As per the importer.
> > 
> > let attrs = s.attributesAtIndex(0, effectiveRange:nil) // In Swift 2,  
> > ‘attrs’ has type [NSObject : AnyObject]  
> > let fontName = attrs[SomeNSFontAttributeName] // This will fail to compile  
> > without an implicit conversion from String to NSString.
> > 
> > For this reason, we decided to make a compromise. We would require  
> > explicit bridging casts when converting from a bridged Objective-C type to  
> > its associated Swift value type (E.g., NSString -\> String), but not the  
> > other way around. This would improve the status quo somewhat, and would  
> > also avoid breaking user code in a needless/painful fashion until we could  
> > get better API annotations in place.
> > 
> > With the introduction of Objective-C generics last year, along with all of  
> > the awesome improvements to API importing happening for Swift 3, I think  
> > it’s time that we take another look at completing this work. Taking a look  
> > back at last year’s “problematic” APIs, all of them now surface richer type  
> > information when imported into Swift 3. As a result, the remaining implicit  
> > bridging conversions now feel far less necessary, since Objective-C APIs  
> > are now more commonly exposed in terms of their appropriate bridged Swift  
> > value types. (For instance, in Swift 3, the above reference to attrs will  
> > import as [String : AnyObject].)
> > 
> > I propose that we fully eliminate implicit bridging conversions in Swift  
> > 3. This would mean that some users might have to introduce introduce a few  
> > more ‘as’ casts in their code, but we would remove another special case  
> > from Swift's type system and be able to further simplify the compiler. If  
> > anyone is curious and would like to take this model for a spin, I’ve pushed  
> > an experimental branch that implements this proposed change,  
> > inhibit-implicit-conversions.
> > 
> > Thoughts?
> > 
> > Thanks!  
> > - Joe  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![Joe\_Pamer](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Joe\_Pamer](https://forums.swift.org/u/Joe_Pamer)\
**Post date:** [April 19, 2016, 5:17pm UTC](https://forums.swift.org/t/pitch-fully-eliminate-implicit-bridging-conversions-in-swift-3/2256/7 "2016-04-19T17:17:51Z")

</div>

> > I propose that we fully eliminate implicit bridging conversions in Swift 3. This would mean that some users might have to introduce introduce a few more ‘as’ casts in their code, but we would remove another special case from Swift's type system and be able to further simplify the compiler. If anyone is curious and would like to take this model for a spin, I’ve pushed an experimental branch that implements this proposed change, inhibit-implicit-conversions.
> 
> What happens with string literals? Are they implicitly converted to NSString as necessary?

Sort of - yes. The types of literal expressions are always inferred from context, so for string literals they will be inferred as NSString or String as necessary.

> Which of the following will be legal?
> 
> &nbsp;&nbsp;&nbsp;&nbsp;import Foundation  
> &nbsp;&nbsp;&nbsp;&nbsp;func s(\_ str: String) { }  
> &nbsp;&nbsp;&nbsp;&nbsp;func ns(\_ str: NSString) { }
> 
> &nbsp;&nbsp;&nbsp;&nbsp;let str: String = "foo"  
> &nbsp;&nbsp;&nbsp;&nbsp;let nsstr: NSString = "foo"
> 
> &nbsp;&nbsp;&nbsp;&nbsp;NSLog("foo”)

legal

> &nbsp;&nbsp;&nbsp;&nbsp;NSLog(str)

legal - the NSLog initializer is imported as having type func NSLog(\_ format: String, \_ args: CVarArg...)

> &nbsp;&nbsp;&nbsp;&nbsp;NSLog(nstr)

illegal, per the imported initializer declaration above

> &nbsp;&nbsp;&nbsp;&nbsp;s("foo”)

legal

> &nbsp;&nbsp;&nbsp;&nbsp;s(str)

legal

> &nbsp;&nbsp;&nbsp;&nbsp;s(nsstr)

illegal

> &nbsp;&nbsp;&nbsp;&nbsp;ns("foo”)

legal

> &nbsp;&nbsp;&nbsp;&nbsp;ns(str)

illegal

> &nbsp;&nbsp;&nbsp;&nbsp;ns(nsstr)

legal

Thanks,  
- Joe

> **···**
>
> > On Apr 19, 2016, at 7:28 AM, Greg Parker \<gparker@apple.com\> wrote:
> > 
> > > On Apr 18, 2016, at 8:21 PM, Joe Pamer via swift-evolution \<swift-evolution@swift.org \<mailto:swift-evolution@swift.org\>\> wrote:
> 
> > --  
> > Greg Parker gparker@apple.com \<mailto:gparker@apple.com\> Runtime Wrangler
