Skip to content

Change all remaining tests to use associatedtype instead of typealias in protocols #1557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/1_stdlib/BridgeStorage.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import Swift
import SwiftShims

protocol BridgeStorage {
typealias Native : AnyObject
typealias ObjC : AnyObject
associatedtype Native : AnyObject
associatedtype ObjC : AnyObject

init(native: Native, bits: Int)
init(native: Native)
Expand Down
6 changes: 3 additions & 3 deletions test/1_stdlib/TypeName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ enum E {}
protocol P {}
protocol P2 {}
protocol AssociatedTypes {
typealias A
typealias B
typealias C
associatedtype A
associatedtype B
associatedtype C
}

class Model : AssociatedTypes {
Expand Down
2 changes: 1 addition & 1 deletion test/DebugInfo/archetype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ protocol IntegerArithmetic {
}

protocol RandomAccessIndex : IntegerArithmetic {
typealias Distance : IntegerArithmetic
associatedtype Distance : IntegerArithmetic
static func uncheckedSubtract(lhs: Self, rhs: Self) -> (Distance, Bool)
}

Expand Down
6 changes: 3 additions & 3 deletions test/IDE/annotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ func foo(n : Float) -> Int {
}

// CHECK-LABEL: protocol <Protocol>Prot</Protocol> {
// CHECK-NEXT: typealias <AssociatedType>Blarg</AssociatedType>
// CHECK-NEXT: associatedtype <AssociatedType>Blarg</AssociatedType>
// CHECK-NEXT: func <Func>protMeth</Func>(<Param>x</Param>: <iStruct@>Int</iStruct>)
// CHECK-NEXT: var <Var>protocolProperty1</Var>: <iStruct@>Int</iStruct> { get }
// CHECK-NEXT: var <Var>protocolProperty2</Var>: <iStruct@>Int</iStruct> { get set }
// CHECK-NEXT: }
protocol Prot {
typealias Blarg
associatedtype Blarg
func protMeth(x: Int)
var protocolProperty1: Int { get }
var protocolProperty2: Int { get set }
Expand All @@ -81,7 +81,7 @@ class SubCls : MyCls, Prot {
var protocolProperty2 = 0
}

// 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> {}{{$}}
// 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> {}{{$}}
func genFn<T : Prot where T.Blarg : Prot2>(p : T) -> Int {}

func test(x: Int) {
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/comment_attach.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class decl_class_1 {
/// decl_protocol_1 Aaa.
protocol decl_protocol_1 {
/// NestedTypealias Aaa.
typealias NestedTypealias
associatedtype NestedTypealias

/// instanceFunc1 Aaa.
func instanceFunc1()
Expand Down Expand Up @@ -293,7 +293,7 @@ func unterminatedBlockDocComment() {}
// CHECK-NEXT: comment_attach.swift:177:15: EnumElement/decl_enum_1.Case5 RawComment=[/// Case4 Case5 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:181:7: Class/decl_class_1 RawComment=[/// decl_class_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:185:10: Protocol/decl_protocol_1 RawComment=[/// decl_protocol_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:187:13: AssociatedType/decl_protocol_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
// CHECK-NEXT: comment_attach.swift:187:18: AssociatedType/decl_protocol_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
// CHECK-NEXT: comment_attach.swift:190:8: Func/decl_protocol_1.instanceFunc1 RawComment=[/// instanceFunc1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:193:7: Var/decl_protocol_1.propertyWithGet RawComment=[/// propertyWithGet Aaa.\n]
// CHECK-NEXT: comment_attach.swift:193:30: Func/decl_protocol_1.<getter for decl_protocol_1.propertyWithGet> RawComment=none
Expand Down
2 changes: 1 addition & 1 deletion test/IDE/complete_from_stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func testArchetypeReplacement3 (a : [Int]) {


protocol P2 {
typealias MyElement
associatedtype MyElement
}

extension P2 {
Expand Down
2 changes: 1 addition & 1 deletion test/IDE/complete_operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func testPostfix8(x: S) {
// POSTFIX_8-NOT: ***

protocol P {
typealias T
associatedtype T
func foo() -> T
}

Expand Down
6 changes: 3 additions & 3 deletions test/IDE/complete_value_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ func testGenericConforming3<T: P3>(x: T) {

struct OnlyMe {}
protocol P4 {
typealias T
associatedtype T
}
extension P4 where Self.T : P1 {
final func extP4WhenP1() {}
Expand Down Expand Up @@ -1724,7 +1724,7 @@ extension P4 where Self.T == WillConformP1 {
// PROTOCOL_EXT_P4_T_DOT_1: End completions

protocol PWithT {
typealias T
associatedtype T
func foo(x: T) -> T
}

Expand All @@ -1745,7 +1745,7 @@ func testUnusableProtExt(x: PWithT) {
// PROTOCOL_EXT_UNUSABLE_EXISTENTIAL: End completions

protocol dedupP {
typealias T
associatedtype T
func foo() -> T
var bar: T {get}
subscript(x: T) -> T {get}
Expand Down
6 changes: 3 additions & 3 deletions test/IRGen/associated_type_witness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ protocol P {}
protocol Q {}

protocol Assocked {
typealias Assoc : P, Q
associatedtype Assoc : P, Q
}

struct Universal : P, Q {}
Expand Down Expand Up @@ -124,7 +124,7 @@ struct Computed<T, U> : Assocked {

struct PBox<T: P> {}
protocol HasSimpleAssoc {
typealias Assoc
associatedtype Assoc
}
protocol DerivedFromSimpleAssoc : HasSimpleAssoc {}

Expand Down Expand Up @@ -163,7 +163,7 @@ struct GenericComputed<T: P> : DerivedFromSimpleAssoc {


protocol HasAssocked {
typealias Contents : Assocked
associatedtype Contents : Assocked
}
struct FulfilledFromAssociatedType<T : HasAssocked> : HasSimpleAssoc {
typealias Assoc = PBox<T.Contents.Assoc>
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/dependent_reabstraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
func markUsed<T>(t: T) {}

protocol A {
typealias B
associatedtype B
func b(_: B)
}

Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/infinite_archetype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// REQUIRES: CPU=i386_or_x86_64

protocol Fooable {
typealias Foo
associatedtype Foo
}

// CHECK: define hidden void @_TF18infinite_archetype3foo{{.*}}(%swift.opaque* noalias nocapture sret, %swift.opaque* noalias nocapture, %swift.type* %T, i8** %T.Fooable)
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/partial_apply_generic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func ~> <Target, Args, Result> (
}

protocol Runcible {
typealias Element
associatedtype Element
}

struct Mince {}
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/protocol_extensions_constrain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public protocol P1 {
}

public protocol P2 {
typealias Index : P1
associatedtype Index : P1

var startIndex: Index {get}
}
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/same_type_constraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public struct DefaultFoo<T> {
}

public protocol P {
typealias Foo
associatedtype Foo
}

public extension P where Foo == DefaultFoo<Self> {
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/sil_witness_tables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import sil_witness_tables_external_conformance
protocol A {}

protocol P {
typealias Assoc: A
associatedtype Assoc: A

static func staticMethod()
func instanceMethod()
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/witness_table_objc_associated_type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
protocol A {}

protocol B {
typealias AA: A
associatedtype AA: A
func foo()
}

@objc protocol O {}

protocol C {
typealias OO: O
associatedtype OO: O
func foo()
}

Expand Down
2 changes: 1 addition & 1 deletion test/Interpreter/dependent_reabstraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// REQUIRES: executable_test

protocol A {
typealias B
associatedtype B
func b(_: B)
}

Expand Down
2 changes: 1 addition & 1 deletion test/Interpreter/function_metatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// REQUIRES: executable_test

protocol ProtocolHasInOut {
typealias Input
associatedtype Input
typealias Mutator = (inout Input) -> ()
var f: Mutator { get }
}
Expand Down
16 changes: 9 additions & 7 deletions test/Prototypes/CollectionTransformers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ internal func _splitRandomAccessIndexRange<Index : RandomAccessIndex>(
/// Using a builder can be more efficient than creating an empty collection
/// instance and adding elements one by one.
public protocol CollectionBuilder {
typealias Destination : Collection
typealias Element = Destination.Iterator.Element
associatedtype Destination : Collection

// FIXME: should really be a typealias once that is supported
associatedtype Element = Destination.Iterator.Element

init()

Expand Down Expand Up @@ -118,7 +120,7 @@ public protocol CollectionBuilder {
}

public protocol BuildableCollectionProtocol : Collection {
typealias Builder : CollectionBuilder
associatedtype Builder : CollectionBuilder
}

extension Array : SplittableCollection {
Expand Down Expand Up @@ -518,7 +520,7 @@ final class _ForkJoinWorkerThread {
}

internal protocol _Future {
typealias Result
associatedtype Result

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

internal protocol _CollectionTransformerStepProtocol /*: class*/ {
typealias PipelineInputElement
typealias OutputElement
associatedtype PipelineInputElement
associatedtype OutputElement

func transform<
InputCollection : Collection,
Expand Down Expand Up @@ -1070,7 +1072,7 @@ struct _ElementCollectorOneToMaybeOne<
}

protocol _ElementCollector {
typealias Element
associatedtype Element

mutating func sizeHint(approximateSize: Int)

Expand Down
4 changes: 2 additions & 2 deletions test/Prototypes/FloatingPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public protocol FloatingPoint : Comparable, SignedNumber,
FloatLiteralConvertible {

/// An unsigned integer type large enough to hold the significand field.
typealias SignificandBits: FloatingPointRepresentation
associatedtype SignificandBits: FloatingPointRepresentation

/// Positive infinity.
///
Expand Down Expand Up @@ -841,7 +841,7 @@ extension BinaryFloatingPoint {
public protocol FloatingPointInterchange: FloatingPoint {

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

/// Interpret `encoding` as a little-endian encoding of `Self`.
init(littleEndian encoding: BitPattern)
Expand Down
6 changes: 3 additions & 3 deletions test/Prototypes/Integers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public protocol IntegerType
// possible, and we really need to factor IntegerType differently
// than it currently is so we can remove the constraints on
// AbsoluteValue in the multiprecision multiplication routines.
typealias AbsoluteValue : Comparable, ArithmeticType,
associatedtype AbsoluteValue : Comparable, ArithmeticType,
IntegerLiteralConvertible, CustomStringConvertible

var absoluteValue: AbsoluteValue { get }
Expand Down Expand Up @@ -649,7 +649,7 @@ public func &${x.operator} <T: FixedWidthIntegerType>(lhs: T, rhs: T) -> T {
//===--- UnsignedIntegerType ----------------------------------------------===//
//===----------------------------------------------------------------------===//
public protocol UnsignedIntegerType : IntegerType {
typealias AbsoluteValue : IntegerType
associatedtype AbsoluteValue : IntegerType
}

extension UnsignedIntegerType {
Expand Down Expand Up @@ -731,7 +731,7 @@ extension UnsignedIntegerType where Self : FixedWidthIntegerType {
//===----------------------------------------------------------------------===//

public protocol SignedIntegerType : IntegerType {
typealias AbsoluteValue : IntegerType
associatedtype AbsoluteValue : IntegerType
}

extension SignedIntegerType {
Expand Down
4 changes: 2 additions & 2 deletions test/Prototypes/TextFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protocol XStreamable {
/// declare conformance: simply give the type a debugFormat().
protocol XDebugPrintable {

typealias DebugRepresentation : XStreamable // = String
associatedtype DebugRepresentation : XStreamable // = String

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

/// \brief produce a "pretty" textual representation that can be
/// distinct from the debug format. For example,
Expand Down
4 changes: 2 additions & 2 deletions test/SIL/Parser/generic_signature_with_depth.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RUN: %target-swift-frontend %s -emit-silgen | %target-sil-opt | FileCheck %s

protocol mmGeneratorType {
typealias Element
associatedtype Element
}

protocol mmSequenceType {
typealias Generator : mmGeneratorType
associatedtype Generator : mmGeneratorType
}

protocol mmCollectionType : mmSequenceType {
Expand Down
2 changes: 1 addition & 1 deletion test/SIL/Parser/generics.sil
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sil [transparent] @_TTRXFo_iBi32__dT__XFo_dBi32__dT__ : $@convention(thin) (Buil

protocol FooProtoHelper {}
protocol FooProto {
typealias Assoc : FooProtoHelper
associatedtype Assoc : FooProtoHelper
var value: Assoc { get }
}

Expand Down
2 changes: 1 addition & 1 deletion test/SIL/Parser/where.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Swift
protocol P {
typealias CodeUnit
associatedtype CodeUnit
mutating func decode<
G : IteratorProtocol where G.Element == CodeUnit
>(next: inout G) -> Int
Expand Down
4 changes: 2 additions & 2 deletions test/SIL/Parser/where_clause.sil
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Make sure we can parse where clause with conformance & same-type requirements.

protocol Runcible {
typealias Mince
typealias Quince
associatedtype Mince
associatedtype Quince
}

struct Spoon<T: Runcible> {}
Expand Down
Loading