File: default_arguments_inherited.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (40 lines) | stat: -rw-r--r-- 1,695 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// RUN: %target-swift-emit-silgen %s | %FileCheck %s

// When we synthesize an inherited designated initializer, the default
// arguments are still conceptually rooted on the base declaration.
// When we call such an initializer, we have to construct substitutions
// in terms of the base class generic signature, rather than the
// derived class generic signature.

class Puppy<T, U> {
  init(t: T? = (nil), u: U? = (nil)) {}
}

class Chipmunk : Puppy<Int, String> {}

class Kitten<V> : Puppy<Int, V> {}

class Goldfish<T> {
  class Shark<U> : Puppy<T, U> {}
}

// CHECK-LABEL: sil hidden [ossa] @$s27default_arguments_inherited4doItyyF : $@convention(thin) () -> () {
func doIt() {
  // CHECK: [[ARG1:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA_
  // CHECK: apply [[ARG1]]<Int, String>({{.*}})
  // CHECK: [[ARG2:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA0_
  // CHECK: apply [[ARG2]]<Int, String>({{.*}})
  _ = Chipmunk()

  // CHECK: [[ARG1:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA_
  // CHECK: apply [[ARG1]]<Int, String>(%{{.*}})
  // CHECK: [[ARG2:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA0_
  // CHECK: apply [[ARG2]]<Int, String>(%{{.*}})
  _ = Kitten<String>()

  // CHECK: [[ARG1:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA_
  // CHECK: apply [[ARG1]]<String, Int>(%{{.*}})
  // CHECK: [[ARG2:%.*]] = function_ref @$s27default_arguments_inherited5PuppyC1t1uACyxq_GxSg_q_SgtcfcfA0_
  // CHECK: apply [[ARG2]]<String, Int>(%{{.*}})
  _ = Goldfish<String>.Shark<Int>()
}