<commit_before>// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test

// XFAIL: linux

class C {}
struct S {}
enum E {}

protocol P {}
protocol P2 {}
protocol AssociatedTypes {
  typealias A
  typealias B
  typealias C
}

class Model : AssociatedTypes {
  typealias A = C
  typealias B = S
  typealias C = E
}

struct Model2 : AssociatedTypes {
  typealias A = C
  typealias B = S
  typealias C = E
}

class GC<T : AssociatedTypes> {}
struct GS<T : AssociatedTypes> {}
enum GE<T : AssociatedTypes> {}
class GC2<T : AssociatedTypes, U : AssociatedTypes> {}

func printTypeName(t: Any.Type) { print(_typeName(t)) }

printTypeName(Int.self) // CHECK: Swift.Int
printTypeName(C.self) // CHECK-NEXT: [[THIS:.*]].C
printTypeName(S.self) // CHECK-NEXT: [[THIS]].S
printTypeName(E.self) // CHECK-NEXT: [[THIS]].E
printTypeName(GC<Model>.self) // CHECK-NEXT: [[THIS]].GC<[[THIS]].Model>
printTypeName(GS<Model>.self) // CHECK-NEXT: [[THIS]].GS<[[THIS]].Model>
printTypeName(GE<Model>.self) // CHECK-NEXT: [[THIS]].GE<[[THIS]].Model>
printTypeName(GC2<Model, Model2>.self) // CHECK-NEXT: [[THIS]].GC2<[[THIS]].Model, [[THIS]].Model2>

printTypeName(P.self) // CHECK-NEXT: [[THIS]].P
typealias PP2 = protocol<P, P2>
printTypeName(PP2.self) // CHECK-NEXT: protocol<[[THIS]].P, [[THIS]].P2>
printTypeName(Any.self) // CHECK-NEXT: protocol<>

typealias F = () -> ()
typealias F2 = () -> () -> ()
typealias F3 = (() -> ()) -> ()

printTypeName(F.self) // CHECK-NEXT: () -> ()
printTypeName(F2.self) // CHECK-NEXT: () -> () -> ()
printTypeName(F3.self) // CHECK-NEXT: (() -> ()) -> ()

typealias B = @convention(block) () -> ()
typealias B2 = () -> @convention(block) () -> ()
typealias B3 = (@convention(block) () -> ()) -> ()

printTypeName(B.self) // CHECK-NEXT: @convention(block) () -> ()
printTypeName(B2.self) // CHECK-NEXT: () -> @convention(block) () -> ()
printTypeName(B3.self) // CHECK-NEXT: (@convention(block) () -> ()) -> ()

printTypeName(F.Type.self) // CHECK-NEXT: (() -> ()).Type
printTypeName(C.Type.self) // CHECK-NEXT: [[THIS]].C.Type
printTypeName(C.Type.Type.self) // CHECK-NEXT: [[THIS]].C.Type.Type
printTypeName(Any.Type.self) // CHECK-NEXT: protocol<>.Type
printTypeName(Any.Protocol.self) // CHECK-NEXT: protocol<>.Protocol
printTypeName(AnyObject.self) // CHECK-NEXT: {{^}}Swift.AnyObject{{$}}
printTypeName(AnyClass.self) // CHECK-NEXT: {{^}}Swift.AnyObject.Type{{$}}
printTypeName((AnyObject?).self) // CHECK-NEXT: {{^}}Swift.Optional<Swift.AnyObject>{{$}}

printTypeName(Void.self) // CHECK-NEXT: ()
typealias Tup = (Any, F, C)
printTypeName(Tup.self) // CHECK-NEXT: (protocol<>, () -> (), [[THIS]].C)

typealias IF = inout Int -> ()
typealias IF2 = inout Int -> inout Int -> ()
typealias IF3 = (inout Int -> ()) -> ()
typealias IF3a = (inout (Int -> ())) -> ()
typealias IF3b = inout (Int -> ()) -> ()
typealias IF3c = ((inout Int) -> ()) -> ()
typealias IF4 = inout (() -> ()) -> ()
typealias IF5 = (inout Int, Any) -> ()<commit_msg>Make TypeName.swift test pass on Linux<commit_after>// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test

class C {}
struct S {}
enum E {}

protocol P {}
protocol P2 {}
protocol AssociatedTypes {
  typealias A
  typealias B
  typealias C
}

class Model : AssociatedTypes {
  typealias A = C
  typealias B = S
  typealias C = E
}

struct Model2 : AssociatedTypes {
  typealias A = C
  typealias B = S
  typealias C = E
}

class GC<T : AssociatedTypes> {}
struct GS<T : AssociatedTypes> {}
enum GE<T : AssociatedTypes> {}
class GC2<T : AssociatedTypes, U : AssociatedTypes> {}

func printTypeName(t: Any.Type) { print(_typeName(t)) }

printTypeName(Int.self) // CHECK: Swift.Int
printTypeName(C.self) // CHECK-NEXT: [[THIS:.*]].C
printTypeName(S.self) // CHECK-NEXT: [[THIS]].S
printTypeName(E.self) // CHECK-NEXT: [[THIS]].E
printTypeName(GC<Model>.self) // CHECK-NEXT: [[THIS]].GC<[[THIS]].Model>
printTypeName(GS<Model>.self) // CHECK-NEXT: [[THIS]].GS<[[THIS]].Model>
printTypeName(GE<Model>.self) // CHECK-NEXT: [[THIS]].GE<[[THIS]].Model>
printTypeName(GC2<Model, Model2>.self) // CHECK-NEXT: [[THIS]].GC2<[[THIS]].Model, [[THIS]].Model2>

printTypeName(P.self) // CHECK-NEXT: [[THIS]].P
typealias PP2 = protocol<P, P2>
printTypeName(PP2.self) // CHECK-NEXT: protocol<[[THIS]].P, [[THIS]].P2>
printTypeName(Any.self) // CHECK-NEXT: protocol<>

typealias F = () -> ()
typealias F2 = () -> () -> ()
typealias F3 = (() -> ()) -> ()

printTypeName(F.self) // CHECK-NEXT: () -> ()
printTypeName(F2.self) // CHECK-NEXT: () -> () -> ()
printTypeName(F3.self) // CHECK-NEXT: (() -> ()) -> ()

#if _runtime(_ObjC)
typealias B = @convention(block) () -> ()
typealias B2 = () -> @convention(block) () -> ()
typealias B3 = (@convention(block) () -> ()) -> ()
printTypeName(B.self)
printTypeName(B2.self)
printTypeName(B3.self)
#else
print("@convention(block) () -> ()")
print("() -> @convention(block) () -> ()")
print("(@convention(block) () -> ()) -> ()")
#endif
// CHECK-NEXT: @convention(block) () -> ()
// CHECK-NEXT: () -> @convention(block) () -> ()
// CHECK-NEXT: (@convention(block) () -> ()) -> ()

printTypeName(F.Type.self) // CHECK-NEXT: (() -> ()).Type
printTypeName(C.Type.self) // CHECK-NEXT: [[THIS]].C.Type
printTypeName(C.Type.Type.self) // CHECK-NEXT: [[THIS]].C.Type.Type
printTypeName(Any.Type.self) // CHECK-NEXT: protocol<>.Type
printTypeName(Any.Protocol.self) // CHECK-NEXT: protocol<>.Protocol
printTypeName(AnyObject.self) // CHECK-NEXT: {{^}}Swift.AnyObject{{$}}
printTypeName(AnyClass.self) // CHECK-NEXT: {{^}}Swift.AnyObject.Type{{$}}
printTypeName((AnyObject?).self) // CHECK-NEXT: {{^}}Swift.Optional<Swift.AnyObject>{{$}}

printTypeName(Void.self) // CHECK-NEXT: ()
typealias Tup = (Any, F, C)
printTypeName(Tup.self) // CHECK-NEXT: (protocol<>, () -> (), [[THIS]].C)

typealias IF = inout Int -> ()
typealias IF2 = inout Int -> inout Int -> ()
typealias IF3 = (inout Int -> ()) -> ()
typealias IF3a = (inout (Int -> ())) -> ()
typealias IF3b = inout (Int -> ()) -> ()
typealias IF3c = ((inout Int) -> ()) -> ()
typealias IF4 = inout (() -> ()) -> ()
typealias IF5 = (inout Int, Any) -> ()
{'fraction_non_alphanumeric': 0.23188879803761242, 'fraction_numerical': 0.008503679476696648, 'mean_word_length': 4.050371593724195, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 118, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6932799', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2234, 'n_words': 427}