@@ -116,3 +116,30 @@ func testGenericPointerConversions(
116116 // Make sure this is ambiguous.
117117 ptr. foo ( chars) // expected-error {{ambiguous use of 'foo'}}
118118}
119+
120+ // Make sure we prefer non-pack overloads when pointer conversions are involved.
121+ func testOverloadedPackPointerConversions( ) {
122+ func takesPtr( _ ptr: UnsafePointer < CChar > ) { }
123+
124+ // Deprecation does not impact solution score, so we can use it to ensure
125+ // we don't pick it.
126+ @available ( * , deprecated, message: " shouldn't have picked this overload " )
127+ func packOverloaded1< each T , R> ( _ xs: repeat each T , fn: ( repeat each T ) -> R ? ) { }
128+ func packOverloaded1< T, R> ( _ x: T , fn: ( T ) -> R ? ) { }
129+ packOverloaded1 ( " " ) { takesPtr ( $0) }
130+
131+ @available ( * , deprecated, message: " shouldn't have picked this overload " )
132+ func packOverloaded2< each T , R> ( _ xs: ( repeat each T ) ? , fn: ( repeat each T ) -> R ? ) { }
133+ func packOverloaded2< T, R> ( _ x: T ? , fn: ( T ) -> R ? ) { }
134+ packOverloaded2 ( " " ) { takesPtr ( $0) }
135+
136+ @available ( * , deprecated, message: " shouldn't have picked this overload " )
137+ func packOverloaded3< each T , R> ( _ xs: repeat ( each T ) ? , fn: ( repeat each T ) -> R ? ) { }
138+ func packOverloaded3< T, R> ( _ x: T ? , fn: ( T ) -> R ? ) { }
139+ packOverloaded3 ( " " ) { takesPtr ( $0) }
140+
141+ @available ( * , deprecated, message: " shouldn't have picked this overload " )
142+ func packOverloaded4< each T , R> ( _ xs: ( repeat ( each T ) ? ) ? , fn: ( repeat each T ) -> R ? ) { }
143+ func packOverloaded4< T, R> ( _ x: T ? ? , fn: ( T ) -> R ? ) { }
144+ packOverloaded4 ( " " ) { takesPtr ( $0) }
145+ }
0 commit comments