Skip to content

Commit 78216b2

Browse files
committed
Change all remaining tests that use typealias in a protocol to use associatedtype.
1 parent 6ed4eba commit 78216b2

File tree

94 files changed

+170
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+170
-166
lines changed

test/1_stdlib/BridgeStorage.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import Swift
2828
import SwiftShims
2929

3030
protocol BridgeStorage {
31-
typealias Native : AnyObject
32-
typealias ObjC : AnyObject
31+
associatedtype Native : AnyObject
32+
associatedtype ObjC : AnyObject
3333

3434
init(native: Native, bits: Int)
3535
init(native: Native)

test/1_stdlib/TypeName.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ enum E {}
88
protocol P {}
99
protocol P2 {}
1010
protocol AssociatedTypes {
11-
typealias A
12-
typealias B
13-
typealias C
11+
associatedtype A
12+
associatedtype B
13+
associatedtype C
1414
}
1515

1616
class Model : AssociatedTypes {

test/DebugInfo/archetype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ protocol IntegerArithmetic {
55
}
66

77
protocol RandomAccessIndex : IntegerArithmetic {
8-
typealias Distance : IntegerArithmetic
8+
associatedtype Distance : IntegerArithmetic
99
static func uncheckedSubtract(lhs: Self, rhs: Self) -> (Distance, Bool)
1010
}
1111

test/IDE/annotation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ func foo(n : Float) -> Int {
5656
}
5757

5858
// CHECK-LABEL: protocol <Protocol>Prot</Protocol> {
59-
// CHECK-NEXT: typealias <AssociatedType>Blarg</AssociatedType>
59+
// CHECK-NEXT: associatedtype <AssociatedType>Blarg</AssociatedType>
6060
// CHECK-NEXT: func <Func>protMeth</Func>(<Param>x</Param>: <iStruct@>Int</iStruct>)
6161
// CHECK-NEXT: var <Var>protocolProperty1</Var>: <iStruct@>Int</iStruct> { get }
6262
// CHECK-NEXT: var <Var>protocolProperty2</Var>: <iStruct@>Int</iStruct> { get set }
6363
// CHECK-NEXT: }
6464
protocol Prot {
65-
typealias Blarg
65+
associatedtype Blarg
6666
func protMeth(x: Int)
6767
var protocolProperty1: Int { get }
6868
var protocolProperty2: Int { get set }
@@ -81,7 +81,7 @@ class SubCls : MyCls, Prot {
8181
var protocolProperty2 = 0
8282
}
8383

84-
// CHECK: func <Func>genFn</Func><<GenericTypeParam>T</GenericTypeParam> : <Protocol@64:10>Prot</Protocol> where <GenericTypeParam@85:12>T</GenericTypeParam>.<AssociatedType@65:13>Blarg</AssociatedType> : <Protocol@71:10>Prot2</Protocol>>(<Param>p</Param> : <GenericTypeParam@85:12>T</GenericTypeParam>) -> <iStruct@>Int</iStruct> {}{{$}}
84+
// CHECK: func <Func>genFn</Func><<GenericTypeParam>T</GenericTypeParam> : <Protocol@64:10>Prot</Protocol> where <GenericTypeParam@85:12>T</GenericTypeParam>.<AssociatedType@65:18>Blarg</AssociatedType> : <Protocol@71:10>Prot2</Protocol>>(<Param>p</Param> : <GenericTypeParam@85:12>T</GenericTypeParam>) -> <iStruct@>Int</iStruct> {}{{$}}
8585
func genFn<T : Prot where T.Blarg : Prot2>(p : T) -> Int {}
8686

8787
func test(x: Int) {

test/IDE/comment_attach.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class decl_class_1 {
184184
/// decl_protocol_1 Aaa.
185185
protocol decl_protocol_1 {
186186
/// NestedTypealias Aaa.
187-
typealias NestedTypealias
187+
associatedtype NestedTypealias
188188

189189
/// instanceFunc1 Aaa.
190190
func instanceFunc1()
@@ -293,7 +293,7 @@ func unterminatedBlockDocComment() {}
293293
// CHECK-NEXT: comment_attach.swift:177:15: EnumElement/decl_enum_1.Case5 RawComment=[/// Case4 Case5 Aaa.\n]
294294
// CHECK-NEXT: comment_attach.swift:181:7: Class/decl_class_1 RawComment=[/// decl_class_1 Aaa.\n]
295295
// CHECK-NEXT: comment_attach.swift:185:10: Protocol/decl_protocol_1 RawComment=[/// decl_protocol_1 Aaa.\n]
296-
// CHECK-NEXT: comment_attach.swift:187:13: AssociatedType/decl_protocol_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
296+
// CHECK-NEXT: comment_attach.swift:187:18: AssociatedType/decl_protocol_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
297297
// CHECK-NEXT: comment_attach.swift:190:8: Func/decl_protocol_1.instanceFunc1 RawComment=[/// instanceFunc1 Aaa.\n]
298298
// CHECK-NEXT: comment_attach.swift:193:7: Var/decl_protocol_1.propertyWithGet RawComment=[/// propertyWithGet Aaa.\n]
299299
// CHECK-NEXT: comment_attach.swift:193:30: Func/decl_protocol_1.<getter for decl_protocol_1.propertyWithGet> RawComment=none

test/IDE/complete_from_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func testArchetypeReplacement3 (a : [Int]) {
167167

168168

169169
protocol P2 {
170-
typealias MyElement
170+
associatedtype MyElement
171171
}
172172

173173
extension P2 {

test/IDE/complete_operators.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func testPostfix8(x: S) {
100100
// POSTFIX_8-NOT: ***
101101

102102
protocol P {
103-
typealias T
103+
associatedtype T
104104
func foo() -> T
105105
}
106106

test/IDE/complete_value_expr.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ func testGenericConforming3<T: P3>(x: T) {
15831583
15841584
struct OnlyMe {}
15851585
protocol P4 {
1586-
typealias T
1586+
associatedtype T
15871587
}
15881588
extension P4 where Self.T : P1 {
15891589
final func extP4WhenP1() {}
@@ -1724,7 +1724,7 @@ extension P4 where Self.T == WillConformP1 {
17241724
// PROTOCOL_EXT_P4_T_DOT_1: End completions
17251725
17261726
protocol PWithT {
1727-
typealias T
1727+
associatedtype T
17281728
func foo(x: T) -> T
17291729
}
17301730
@@ -1745,7 +1745,7 @@ func testUnusableProtExt(x: PWithT) {
17451745
// PROTOCOL_EXT_UNUSABLE_EXISTENTIAL: End completions
17461746
17471747
protocol dedupP {
1748-
typealias T
1748+
associatedtype T
17491749
func foo() -> T
17501750
var bar: T {get}
17511751
subscript(x: T) -> T {get}

test/IRGen/associated_type_witness.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ protocol P {}
77
protocol Q {}
88

99
protocol Assocked {
10-
typealias Assoc : P, Q
10+
associatedtype Assoc : P, Q
1111
}
1212

1313
struct Universal : P, Q {}
@@ -124,7 +124,7 @@ struct Computed<T, U> : Assocked {
124124

125125
struct PBox<T: P> {}
126126
protocol HasSimpleAssoc {
127-
typealias Assoc
127+
associatedtype Assoc
128128
}
129129
protocol DerivedFromSimpleAssoc : HasSimpleAssoc {}
130130

@@ -163,7 +163,7 @@ struct GenericComputed<T: P> : DerivedFromSimpleAssoc {
163163

164164

165165
protocol HasAssocked {
166-
typealias Contents : Assocked
166+
associatedtype Contents : Assocked
167167
}
168168
struct FulfilledFromAssociatedType<T : HasAssocked> : HasSimpleAssoc {
169169
typealias Assoc = PBox<T.Contents.Assoc>

test/IRGen/dependent_reabstraction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
func markUsed<T>(t: T) {}
44

55
protocol A {
6-
typealias B
6+
associatedtype B
77
func b(_: B)
88
}
99

test/IRGen/infinite_archetype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// REQUIRES: CPU=i386_or_x86_64
44

55
protocol Fooable {
6-
typealias Foo
6+
associatedtype Foo
77
}
88

99
// CHECK: define hidden void @_TF18infinite_archetype3foo{{.*}}(%swift.opaque* noalias nocapture sret, %swift.opaque* noalias nocapture, %swift.type* %T, i8** %T.Fooable)

test/IRGen/partial_apply_generic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func ~> <Target, Args, Result> (
1616
}
1717

1818
protocol Runcible {
19-
typealias Element
19+
associatedtype Element
2020
}
2121

2222
struct Mince {}

test/IRGen/protocol_extensions_constrain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public protocol P1 {
77
}
88

99
public protocol P2 {
10-
typealias Index : P1
10+
associatedtype Index : P1
1111

1212
var startIndex: Index {get}
1313
}

test/IRGen/same_type_constraints.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public struct DefaultFoo<T> {
66
}
77

88
public protocol P {
9-
typealias Foo
9+
associatedtype Foo
1010
}
1111

1212
public extension P where Foo == DefaultFoo<Self> {

test/IRGen/sil_witness_tables.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import sil_witness_tables_external_conformance
1212
protocol A {}
1313

1414
protocol P {
15-
typealias Assoc: A
15+
associatedtype Assoc: A
1616

1717
static func staticMethod()
1818
func instanceMethod()

test/IRGen/witness_table_objc_associated_type.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
protocol A {}
44

55
protocol B {
6-
typealias AA: A
6+
associatedtype AA: A
77
func foo()
88
}
99

1010
@objc protocol O {}
1111

1212
protocol C {
13-
typealias OO: O
13+
associatedtype OO: O
1414
func foo()
1515
}
1616

test/Interpreter/dependent_reabstraction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// REQUIRES: executable_test
33

44
protocol A {
5-
typealias B
5+
associatedtype B
66
func b(_: B)
77
}
88

test/Interpreter/function_metatypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// REQUIRES: executable_test
33

44
protocol ProtocolHasInOut {
5-
typealias Input
5+
associatedtype Input
66
typealias Mutator = (inout Input) -> ()
77
var f: Mutator { get }
88
}

test/Prototypes/CollectionTransformers.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ internal func _splitRandomAccessIndexRange<Index : RandomAccessIndex>(
6767
/// Using a builder can be more efficient than creating an empty collection
6868
/// instance and adding elements one by one.
6969
public protocol CollectionBuilder {
70-
typealias Destination : Collection
71-
typealias Element = Destination.Iterator.Element
70+
associatedtype Destination : Collection
71+
72+
// FIXME: should really be a typealias once that is supported
73+
associatedtype Element = Destination.Iterator.Element
7274

7375
init()
7476

@@ -118,7 +120,7 @@ public protocol CollectionBuilder {
118120
}
119121

120122
public protocol BuildableCollectionProtocol : Collection {
121-
typealias Builder : CollectionBuilder
123+
associatedtype Builder : CollectionBuilder
122124
}
123125

124126
extension Array : SplittableCollection {
@@ -518,7 +520,7 @@ final class _ForkJoinWorkerThread {
518520
}
519521

520522
internal protocol _Future {
521-
typealias Result
523+
associatedtype Result
522524

523525
/// Establishes a happens-before relation between completing the future and
524526
/// the call to wait().
@@ -827,8 +829,8 @@ final public class ForkJoinPool {
827829
//===----------------------------------------------------------------------===//
828830

829831
internal protocol _CollectionTransformerStepProtocol /*: class*/ {
830-
typealias PipelineInputElement
831-
typealias OutputElement
832+
associatedtype PipelineInputElement
833+
associatedtype OutputElement
832834

833835
func transform<
834836
InputCollection : Collection,
@@ -1070,7 +1072,7 @@ struct _ElementCollectorOneToMaybeOne<
10701072
}
10711073

10721074
protocol _ElementCollector {
1073-
typealias Element
1075+
associatedtype Element
10741076

10751077
mutating func sizeHint(approximateSize: Int)
10761078

test/Prototypes/FloatingPoint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public protocol FloatingPoint : Comparable, SignedNumber,
3636
FloatLiteralConvertible {
3737

3838
/// An unsigned integer type large enough to hold the significand field.
39-
typealias SignificandBits: FloatingPointRepresentation
39+
associatedtype SignificandBits: FloatingPointRepresentation
4040

4141
/// Positive infinity.
4242
///
@@ -841,7 +841,7 @@ extension BinaryFloatingPoint {
841841
public protocol FloatingPointInterchange: FloatingPoint {
842842

843843
/// An unsigned integer type used to represent floating-point encodings.
844-
typealias BitPattern: FloatingPointRepresentation
844+
associatedtype BitPattern: FloatingPointRepresentation
845845

846846
/// Interpret `encoding` as a little-endian encoding of `Self`.
847847
init(littleEndian encoding: BitPattern)

test/Prototypes/Integers.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public protocol IntegerType
187187
// possible, and we really need to factor IntegerType differently
188188
// than it currently is so we can remove the constraints on
189189
// AbsoluteValue in the multiprecision multiplication routines.
190-
typealias AbsoluteValue : Comparable, ArithmeticType,
190+
associatedtype AbsoluteValue : Comparable, ArithmeticType,
191191
IntegerLiteralConvertible, CustomStringConvertible
192192

193193
var absoluteValue: AbsoluteValue { get }
@@ -649,7 +649,7 @@ public func &${x.operator} <T: FixedWidthIntegerType>(lhs: T, rhs: T) -> T {
649649
//===--- UnsignedIntegerType ----------------------------------------------===//
650650
//===----------------------------------------------------------------------===//
651651
public protocol UnsignedIntegerType : IntegerType {
652-
typealias AbsoluteValue : IntegerType
652+
associatedtype AbsoluteValue : IntegerType
653653
}
654654

655655
extension UnsignedIntegerType {
@@ -731,7 +731,7 @@ extension UnsignedIntegerType where Self : FixedWidthIntegerType {
731731
//===----------------------------------------------------------------------===//
732732

733733
public protocol SignedIntegerType : IntegerType {
734-
typealias AbsoluteValue : IntegerType
734+
associatedtype AbsoluteValue : IntegerType
735735
}
736736

737737
extension SignedIntegerType {

test/Prototypes/TextFormatting.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protocol XStreamable {
3535
/// declare conformance: simply give the type a debugFormat().
3636
protocol XDebugPrintable {
3737

38-
typealias DebugRepresentation : XStreamable // = String
38+
associatedtype DebugRepresentation : XStreamable // = String
3939

4040
/// \brief Produce a textual representation for the REPL and
4141
/// Debugger.
@@ -89,7 +89,7 @@ func ~> <T:XDebugPrintable> (x: T, _: __PrintedFormat) -> T.DebugRepresentation
8989
/// to do is declare conformance to XPrintable, and there's nothing to
9090
/// implement.
9191
protocol XPrintable: XDebugPrintable {
92-
typealias PrintRepresentation: XStreamable = DebugRepresentation
92+
associatedtype PrintRepresentation: XStreamable = DebugRepresentation
9393

9494
/// \brief produce a "pretty" textual representation that can be
9595
/// distinct from the debug format. For example,

test/SIL/Parser/generic_signature_with_depth.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: %target-swift-frontend %s -emit-silgen | %target-sil-opt | FileCheck %s
22

33
protocol mmGeneratorType {
4-
typealias Element
4+
associatedtype Element
55
}
66

77
protocol mmSequenceType {
8-
typealias Generator : mmGeneratorType
8+
associatedtype Generator : mmGeneratorType
99
}
1010

1111
protocol mmCollectionType : mmSequenceType {

test/SIL/Parser/generics.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ sil [transparent] @_TTRXFo_iBi32__dT__XFo_dBi32__dT__ : $@convention(thin) (Buil
9191

9292
protocol FooProtoHelper {}
9393
protocol FooProto {
94-
typealias Assoc : FooProtoHelper
94+
associatedtype Assoc : FooProtoHelper
9595
var value: Assoc { get }
9696
}
9797

test/SIL/Parser/where.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Swift
44
protocol P {
5-
typealias CodeUnit
5+
associatedtype CodeUnit
66
mutating func decode<
77
G : IteratorProtocol where G.Element == CodeUnit
88
>(next: inout G) -> Int

test/SIL/Parser/where_clause.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Make sure we can parse where clause with conformance & same-type requirements.
55

66
protocol Runcible {
7-
typealias Mince
8-
typealias Quince
7+
associatedtype Mince
8+
associatedtype Quince
99
}
1010

1111
struct Spoon<T: Runcible> {}

0 commit comments

Comments
 (0)