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

// Test IR generation via execution for Self.

protocol P {
  func f() -> Self
  func g() -> Self
}

protocol CP : class {
  func f() -> Self
  func g() -> Self
}

func callDynamicSelfExistential(_ p: P) {
  print("Before first call")
  var p2 = p.f()
  print("Between calls")
  p2.g()
  print("After second call")
}

func callDynamicSelfClassExistential(_ cp: CP) {
  print("Before first call")
  var cp2 = cp.f()
  print("Between calls")
  cp2.g()
  print("After second call")
}

struct S : P {
  func f() -> S {
    print("S.f()")
    return self
  }

  func g() -> S {
    print("S.g()")
    return self
  }
}

class C : P, CP {
  init() {
    print("Allocating C")
  }

  deinit {
    print("Destroying C")
  }

  func f() -> Self {
    print("C.f()")
    return self
  }

  func g() -> Self {
    print("C.g()")
    return self
  }
}

print("-------------------------------")

// CHECK: S() as non-class existential
print("S() as non-class existential")
// CHECK-NEXT: Before first call
// CHECK-NEXT: S.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: S.g()
// CHECK-NEXT: After second call
callDynamicSelfExistential(S())

// CHECK-NEXT: C() as non-class existential
print("C() as non-class existential")
// CHECK-NEXT: Allocating C
// CHECK-NEXT: Before first call
// CHECK-NEXT: C.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: C.g()
// CHECK-NEXT: After second call
// CHECK-NEXT: Destroying C
callDynamicSelfExistential(C())

// CHECK-NEXT: C() as class existential
print("C() as class existential")
// CHECK-NEXT: Allocating C
// CHECK-NEXT: Before first call
// CHECK-NEXT: C.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: C.g()
// CHECK-NEXT: After second call
// CHECK-NEXT: Destroying C
callDynamicSelfClassExistential(C())

print("-------------------------------")

class Z {<commit_msg>Fix Intepreter/dynamic_self.swift test for ExistentialSpecializer<commit_after>// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test

// Test IR generation via execution for Self.

protocol P {
  func f() -> Self
  func g() -> Self
}

protocol CP : class {
  func f() -> Self
  func g() -> Self
}

func callDynamicSelfExistential(_ p: P) {
  print("Before first call")
  var p2 = p.f()
  print("Between calls")
  p2.g()
  print("After second call")
}

func callDynamicSelfClassExistential(_ cp: CP) {
  print("Before first call")
  var cp2 = cp.f()
  print("Between calls")
  cp2.g()
  print("After second call")
}

struct S : P {
  func f() -> S {
    print("S.f()")
    return self
  }

  func g() -> S {
    print("S.g()")
    return self
  }
}

class C : P, CP {
  init() {
    print("Allocating C")
  }

  func f() -> Self {
    print("C.f()")
    return self
  }

  func g() -> Self {
    print("C.g()")
    return self
  }
}

print("-------------------------------")

// CHECK: S() as non-class existential
print("S() as non-class existential")
// CHECK-NEXT: Before first call
// CHECK-NEXT: S.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: S.g()
// CHECK-NEXT: After second call
callDynamicSelfExistential(S())

// CHECK-NEXT: C() as non-class existential
print("C() as non-class existential")
// CHECK-NEXT: Allocating C
// CHECK-NEXT: Before first call
// CHECK-NEXT: C.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: C.g()
// CHECK-NEXT: After second call
callDynamicSelfExistential(C())

// CHECK-NEXT: C() as class existential
print("C() as class existential")
// CHECK-NEXT: Allocating C
// CHECK-NEXT: Before first call
// CHECK-NEXT: C.f()
// CHECK-NEXT: Between calls
// CHECK-NEXT: C.g()
// CHECK-NEXT: After second call
callDynamicSelfClassExistential(C())

print("-------------------------------")

class Z {
{'fraction_non_alphanumeric': 0.1976558337773042, 'fraction_numerical': 0.002131060202450719, 'mean_word_length': 2.6491739552964044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3611765', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1277, 'n_words': 377}