Skip to content

Commit 1e7a572

Browse files
authored
Merge pull request #7355 from DougGregor/partial-ordering-labels
2 parents 2eb25d4 + 12fc2d2 commit 1e7a572

File tree

6 files changed

+34
-39
lines changed

6 files changed

+34
-39
lines changed

lib/Sema/CSRanking.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,6 @@ static bool isDeclAsSpecializedAs(TypeChecker &tc, DeclContext *dc,
676676
continue;
677677
}
678678

679-
// Labels must match.
680-
if (params1[i].Label != params2[i].Label) return false;
681-
682679
// If one parameter is variadic and the other is not...
683680
if (params1[i].isVariadic() != params2[i].isVariadic()) {
684681
// If the first parameter is the variadic one, it's not

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ set(SWIFTLIB_ESSENTIAL
119119
StringComparable.swift
120120
StringCore.swift
121121
StringHashable.swift
122-
StringInterpolation.swift.gyb
122+
StringInterpolation.swift
123123
StringLegacy.swift
124124
StringRangeReplaceableCollection.swift.gyb
125125
StringIndexConversions.swift
Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- StringInterpolation.swift.gyb - String Interpolation -*- swift -*-===//
1+
//===--- StringInterpolation.swift - String Interpolation -----*- swift -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,30 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
%{
14-
15-
from SwiftIntTypes import all_integer_types
16-
17-
# Number of bits in the Builtin.Word type
18-
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
19-
20-
StreamableTypes = [
21-
'String',
22-
'Character',
23-
'UnicodeScalar',
24-
]
25-
26-
PrintableTypes = [
27-
'Bool',
28-
'Float32',
29-
'Float64'
30-
]
31-
32-
for int_ty in all_integer_types(word_bits):
33-
PrintableTypes.append(int_ty.stdlib_name)
34-
35-
}%
36-
3713
extension String : _ExpressibleByStringInterpolation {
3814
/// Creates a new string by concatenating the given interpolations.
3915
///
@@ -68,31 +44,33 @@ extension String : _ExpressibleByStringInterpolation {
6844
self = String(describing: expr)
6945
}
7046

71-
% for Type in StreamableTypes:
7247
/// Creates a string containing the given value's textual representation.
7348
///
7449
/// Do not call this initializer directly. It is used by the compiler when
7550
/// interpreting string interpolations.
7651
///
7752
/// - SeeAlso: `ExpressibleByStringInterpolation`
78-
public init(stringInterpolationSegment expr: ${Type}) {
53+
public init<T: TextOutputStreamable> (stringInterpolationSegment expr: T) {
7954
self = _toStringReadOnlyStreamable(expr)
8055
}
81-
% end
8256

83-
% for Type in PrintableTypes:
8457
/// Creates a string containing the given value's textual representation.
8558
///
8659
/// Do not call this initializer directly. It is used by the compiler when
8760
/// interpreting string interpolations.
8861
///
8962
/// - SeeAlso: `ExpressibleByStringInterpolation`
90-
public init(stringInterpolationSegment expr: ${Type}) {
63+
public init<T: CustomStringConvertible> (stringInterpolationSegment expr: T) {
9164
self = _toStringReadOnlyPrintable(expr)
9265
}
93-
% end
94-
}
9566

96-
// ${'Local Variables'}:
97-
// eval: (read-only-mode 1)
98-
// End:
67+
/// Creates a string containing the given value's textual representation.
68+
///
69+
/// Do not call this initializer directly. It is used by the compiler when
70+
/// interpreting string interpolations.
71+
///
72+
/// - SeeAlso: `ExpressibleByStringInterpolation`
73+
public init<T: TextOutputStreamable & CustomStringConvertible> (stringInterpolationSegment expr: T) {
74+
self = _toStringReadOnlyStreamable(expr)
75+
}
76+
}

test/Constraints/overload.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,17 @@ func SR3817(_ d: [String : Any], _ s: String, _ t: String) -> Any {
195195
return 0
196196
}
197197
}
198+
199+
// Overloading with mismatched labels.
200+
func f6<T>(foo: T) { }
201+
func f6<T: P1>(bar: T) { }
202+
203+
struct X6 {
204+
init<T>(foo: T) { }
205+
init<T: P1>(bar: T) { }
206+
}
207+
208+
func test_f6() {
209+
let _: (X1a) -> Void = f6
210+
let _: (X1a) -> X6 = X6.init
211+
}

test/api-digester/source-stability.swift.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Protocol IndexableBase has been removed (deprecated)
1212
Protocol MutableIndexable has been removed (deprecated)
1313
Protocol RandomAccessIndexable has been removed (deprecated)
1414
Protocol RangeReplaceableIndexable has been removed (deprecated)
15+
Constructor String.init(stringInterpolationSegment:) has been removed
1516
Func Array.append(contentsOf:) has been removed
1617
Func ArraySlice.append(contentsOf:) has been removed
1718
Func ContiguousArray.append(contentsOf:) has been removed
@@ -34,6 +35,7 @@ Constructor RangeReplaceableBidirectionalSlice.init(base:bounds:) has 2nd parame
3435
Constructor RangeReplaceableRandomAccessSlice.init(base:bounds:) has 2nd parameter type change from Range<Base.Index> to Range<RangeReplaceableRandomAccessSlice.Index>
3536
Constructor RangeReplaceableSlice.init(base:bounds:) has 2nd parameter type change from Range<Base.Index> to Range<RangeReplaceableSlice.Index>
3637
Constructor Slice.init(base:bounds:) has 2nd parameter type change from Range<Base.Index> to Range<Slice.Index>
38+
Constructor String.init(stringInterpolationSegment:) has 1st parameter type change from String to T
3739
Func AnyBidirectionalCollection.makeIterator() has return type change from AnyIterator<Element> to AnyBidirectionalCollection.Iterator
3840
Func AnyCollection.makeIterator() has return type change from AnyIterator<Element> to AnyCollection.Iterator
3941
Func AnyRandomAccessCollection.makeIterator() has return type change from AnyIterator<Element> to AnyRandomAccessCollection.Iterator
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
let query = "<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)&<#...#>=\(<#...#>)"
4+

0 commit comments

Comments
 (0)