WWDC22) Design protocol interfaces in Swift
Learn how you can use Swift 5.7 to design advanced abstractions using protocols. We'll show you how to use existential types, explore how you can separate implementation from interface with opaque result types, and share the same-type requirements that can help you identify and guarantee relationships between concrete types. To get the most out of this session, we recommend first watching βEmbrace Swift generics" from WWDC22.
*λ³Έ κΈμ WWDC λ₯Ό λ³΄κ³ , λ²μ λ° μμ½ κ·Έλ¦¬κ³ μ€νν΄λ³΄λ μ€ν°λ νλ‘μ νΈμ μΌνμ λλ€.
ν΄λΉ μΈμ μλ μΈ κ°μ§ μ£Όμ μ£Όμ κ° μμ΅λλ€.

- μ΄λ»κ²
result type erasure
κ° μλνλμ§ μ€λͺ νμ¬ associated type μ΄ μλ νλ‘ν μ½μ΄ μ΄λ»κ² existentialany
type κ³Ό μνΈμμ©νλ λ°©λ²μ 보μ¬λλ¦¬κ² μ΅λλ€. - ꡬνκ³Ό μΈν°νμ΄μ€λ₯Ό λΆλ¦¬νμ¬ μΊ‘μ νλ₯Ό κ°μ νκΈ° μν΄ opaque result types λ₯Ό μ¬μ©νλ λ°©λ²μ μ€λͺ νκ² μ΅λλ€.
- νλ‘ν μ½μ same-type requirements κ° μ¬λ¬ λ€λ₯Έ concrete types μ μ§ν©κ°μ κ΄κ³λ₯Ό λͺ¨λΈλ§ν μ μλ λ°©λ²μ λ³Ό μ μμ΅λλ€.
Undestand type erasure

Embrace swift generics
μΈμ
μμ Cow μ Chicken μμ μλ‘ λ€λ₯Έ return type μ produce() λ₯Ό μΆμννλ κ°μ₯ μ’μ λ°©λ²μ associated type μ μ¬μ©νλ κ²μ΄ μμ΅λλ€.
associated type μ μ¬μ©νλ©΄ νΉμ νμ μ Animal μ κ²½μ° produce() λ©μλλ₯Ό νΈμΆνλ©΄ νΉμ Animal μ λν νΉμ Food κ° λ°νλ©λλ€.(λ€μ΄μ΄κ·Έλ¨ μ°Έκ³ )
Self
μ νλ‘ν μ½μ μ€μνλ μ€μ concrete type μ
λλ€. Self νμ
μλ Food λ₯Ό μ€μνλ associated type Commodity
κ° μμ΅λλ€. concrete Chicken κ³Ό Cow νμ
κ°μ κ΄κ³μ assocated type λ€μ΄μ΄κ·Έλ¨μ λν΄μ μ΄ν΄λ³΄κ² μ΅λλ€.
Chicken, Cow νμ μ CommodityType(κ°κ° Egg μ Milk) μ κ°μ§ Animal νλ‘ν μ½μ μ€μνκ³ μμ΅λλ€.

μ΄μ any Animal
array κ° μ μ₯λμ΄μλ Farm μ μ΄ν΄λ΄
μλ€.

Embrace Swift generics
μμ μμ보μλ―μ΄ λ€λ₯Έ concrete types μ λν΄ λμΌν ννμ μ¬μ©νλ μ΄λ¬ν μ λ΅μ type erasure
λΌκ³ νμ΅λλ€. produceCommodities()
λ©μλλ κ°λ¨ν΄λ³΄μ΄μ§λ§ type erasure κ° underlying type μ λν static type relationships λ₯Ό μ κ±°νλ κ²μ μκ³ μμ΅λλ€.

existential type μμ associated type μ 리ν΄νλ λ©μλλ₯Ό νΈμΆν λ(produce()
νΈμΆ) μλμ κ°μ΄ μ»΄νμΌλ¬λ type erasure λ₯Ό μ¬μ©νμ¬ νΈμΆμ result type μ κ²°μ ν©λλ€.

concret Animal νμ
κ³Ό associated CommodityType μ any Animal κ³Ό any Food λ‘ λ체νμ¬ κ΄κ³λ₯Ό μ§μ μ΅λλ€. any Food νμ
μ associated CommodityType μ upper bound
λΌκ³ λΆλ¦
λλ€. any Animal μ λν΄μ produce() λ©μλκ° νΈμΆλκΈ° λλ¬Έμ λ°νκ°μ΄ type erase λμ΄μ any Food νμ
κ°μ μ 곡ν©λλ€.
Swift 5.7 μ μλ‘μ΄ κΈ°λ₯μΈ associated-type erasure
κ° μ΄λ»κ² μλνλμ§ μ΄ν΄λ³΄κ² μ΅λλ€.

νλ‘ν μ½ λ©μλμ result type μ λνλλ associated type μ producing position
μ μλ€κ³ ν©λλ€. λ©μλλ₯Ό νΈμΆνλ©΄ μ΄ νμ
μ κ°μ΄ μμ±λκΈ° λλ¬Έμ
λλ€.

produce() λ©μλλ₯Ό any Animal μμ νΈμΆν λ μ°λ¦¬λ μ»΄νμΌ νμμλ concrete result type μ μμ§ λͺ»ν©λλ€. νμ§λ§, upper bound μ subtype μ μ μ μμ΅λλ€.(μ¦, any Food μΈ κ²μ μ μ μμ΅λλ€.)
μμ μμ μμλ λ°νμμμλ any Animal μ΄ Cow μΈ κ²μ μ μ μμ΅λλ€. produce() λ©μλλ Milk λ₯Ό λ°νν©λλ€. Milk λ associated CommodityType μ upper bound μΈ any Food μ μ μ₯λ μ μμ΅λλ€.(μκΉ produceCommodities()
λ©μλμ λ¦¬ν΄ κ°μ΄ any Food μλ€.)
μ΄κ²μ Animal νλ‘ν μ½μ μ€μνλ λͺ¨λ concrete types μκ² νμ μμ νκ² μ μ©λ©λλ€.
λ€λ₯Έμͺ½μΌλ‘ associated type μ΄ λ©μλλ μμ±μμ νλΌλ―Έν°μ λ±μ₯νλ κ²μ μκ°ν΄λ΄ μλ€.

eat()
λ©μλλ associated FeedType μ consuming postion
μ κ°μ§κ³ μμ΅λλ€.

eat λ©μλλ₯Ό νΈμΆνλ €λ©΄ κ°μ νλΌλ―Έν°λ‘ λ겨주μ΄μΌ ν©λλ€. λ³νμ΄ λ°λλ°©ν₯μΌλ‘ μ§νλκΈ° λλ¬Έμ type erasure λ₯Ό μνν μ μμ΅λλ€. associated type μ upper bound λ concrete type μ μ μ μκΈ° λλ¬Έμ μμ νκ² λ³νλμ§ μμ΅λλ€.
Animal νλ‘ν μ½κ³Ό κ΄λ ¨λ FeedType μ upper bound λ any AnimalFeed μ λλ€. κ·Έλ¬λ μμ μν©μ²λΌ any AnimalFeed κ° μ£Όμ΄μ§λ©΄ Hay concrete type μ μ μ μΌλ‘ μ μ₯νλ€λ κ²μ 보μ₯ν λ°©λ²μ΄ μμ΅λλ€. λ€μ μ²λΌμ!

type erasure λ consuming position μ μλ associated types μΌλ‘ μμ
νλ κ²μ νμ©νμ§ μμ΅λλ€. λμ opaque some
type μ μ¬μ©νλ ν¨μμ μ λ¬ν΄μ existential any
type μ μΈλ°μ±ν΄μΌ ν©λλ€.
associated types μ type erasure λμμ μ€μ λ‘ Swift 5.6 μμ λ³Ό μ μλ κΈ°μ‘΄ κΈ°λ₯κ³Ό μ μ¬ν©λλ€. cloning reference type μ μν νλ‘ν μ½μ κ³ λ €ν΄λ³΄μ.
μλμ νλ‘ν μ½μ Self λ₯Ό λ°ννλ clone() λ©μλλ₯Ό μ μν©λλ€. any Cloneable νμ μ κ°μ λν΄ clone() λ©μλλ₯Ό νΈμΆνλ©΄ λ¦¬ν΄ νμ Self κ° upper bound κΉμ§ type erase λ©λλ€. Self μ upper bound λ νμ νλ‘ν μ½ μ체μ΄λ―λ‘ any Cloneable νμ μ μ νμ μ λ°νν©λλ€.

μμ½νμλ©΄ any
λ₯Ό μ¬μ©νμ¬ κ° νμ
μ΄ νλ‘ν μ½μ μ€μνλ concrete type μ μ μ₯νλ existential type μ μ μΈν μ μμ΅λλ€.

μ΄κ²μ associated types κ° μλ νλ‘ν μ½μμλ λμν©λλ€. producing postion μμ associated type μ΄ μλ νλ‘ν μ½ λ©μλλ₯Ό νΈμΆν λ associated type μ upper bound κΉμ§ type erase λ©λλ€.
Hide implementation details
concrete types μ λν μΆμνλ ν¨μ input λΏλ§ μλλΌ oupt μμλ μ μ©νλ―λ‘ concrete types λ ꡬνμμλ§ λ³Ό μ μμ΅λλ€.
concrete result types λ₯Ό μΆμννμ¬ κ΅¬ν μΈλΆ μ 보μμ μ½λμ νμ μΈν°νμ΄μ€λ₯Ό λΆλ¦¬νμ¬ λ λͺ¨λν λκ³ , κ°λ ₯νκ² λ§λλ λ°©λ²μ μ΄ν΄λ³΄κ² μ΅λλ€.
λλ¬Όμκ² λ¨Ήμ΄λ₯Ό μ€ μ μλλ‘ Animal νλ‘ν μ½μ μΌλ°νν΄λ³΄κ²μ΅λλ€. λλ¬Όμ λ°°κ³ νλ©΄ λ¨Ήμ΄μΌ ν©λλ€.

hungryAnimals μ λ°λ³΅μ ν΅ν΄μ λ¨Ήμ΄λ₯Ό μ€ κ² μ
λλ€. μ΄λ feedAnimals() λ©μλκ° νλ²λ§ λ°λ³΅νκΈ° λλ¬Έμ hungryAnimals μ μκ° λ§μ κ²½μ° λΉν¨μ¨μ μ
λλ€. κ·Έλμ lazy.filter
λ‘ λ체ν¨μΌλ‘μ¨ μ°λ¦¬λ μμ ν λΉμ λ°©μ§ν μ μμ΅λλ€.
μ΄μ , hungryAnimals νμ
μ νλ‘νΌν°λ concrete type λ³΄λ€ λ³΅μ‘ν LazyFilterSequence of Array of any Animal
λ‘ μ μΈλμ΄μΌ ν©λλ€.

μ΄κ²μ λΆνμν ꡬν μΈλΆμ¬νμ λ
ΈμΆν©λλ€. ν΄λΌμ΄μΈνΈμΈ feedAnimals() λ hungryAnimals
μ ꡬνμμ lazy.filter
λ₯Ό μ¬μ©ν κ²μ μ κ²½ μ°μ§ μμ΅λλ€. μ΄λ opaque result type μ μ¬μ©ν΄μ μΆμμ μΈ μΈν°νμ΄μ€ λ€μ concrete type μ μ¨κΈΈ μ μμ΅λλ€.

μ΄μ ν΄λΌμ΄μΈνΈλ collection νλ‘ν μ½μ μ€μνλ ꡬ체μ μΈ μ νμ μ»κ³ μλ€λ κ²λ§ μμ§ concrete type μ μμ§ λͺ»ν©λλ€.

κ·Έλ¬λ μμ±λ λλ‘ μ΄κ²μ μ€μ λ‘ ν΄λΌμ΄μΈνΈμμ λ무 λ§μ μ μ μΈ μ 보λ₯Ό μ¨κΉλλ€. hungryAnimals κ° collection μ μ€μνλ concrete type μ μΆλ ₯νλ€κ³ μ μΈνκ³ μμ§λ§, μ΄ collection μ element νμ μ λν΄μλ μ무 κ²λ λͺ¨λ¦ λλ€. element type μ΄ any Animal μ΄λΌλ μ§μ μμ΄λ ν μ μλ κ²μ μ λ¬νλ κ² λΏμ λλ€. μ¦, Animal νλ‘ν μ½ μ λ©μλλ₯Ό νΈμΆν μ μμ΅λλ€.
opaque result type some Collection
μ μ§μ€ν΄ λ³΄κ² μ΅λλ€. ꡬν μΈλΆ μ 보λ₯Ό μ¨κΈ°λ κ²κ³Ό νλΆν μΈν°νμ΄μ€λ₯Ό λ
ΈμΆνλ κ² μ¬μ΄μμ μ¬λ°λ₯Έ κ· νμ μ‘μ μ μμ΅λλ€.
constrained opaqeue result types
λ Swift 5.7 λΆν° μ μ©λλ κ²μ
λλ€.

μ΄κ²μ νλ‘ν μ½ μ΄λ¦ λ€μ κΊΎμ κ΄νΈ μμ type arguments λ₯Ό μ μ©νμ¬ μμ±νλ©΄ λ©λλ€. Collection νλ‘ν μ½μλ λ¨μΌ type argument μΈ Element type μ΄ μμ΅λλ€. μ΄μ hungryAnimals κ° constrained opaque result type μΌλ‘ μ μΈλλ©΄ LazyFilterSequence of Array of any Animal
λΌλ μ¬μ€μ΄ ν΄λΌμ΄μΈνΈμμ μ¨κ²¨μ§λλ€. κ·Έλ¬λ ν΄λΌμ΄μΈνΈλ μ¬μ ν any Animal
κ³Ό κ°μ Element associated type μ κ°μ§ Collection νλ‘ν μ½μ μ€μνλ concrete type μ΄λΌλ κ²μ μ¬μ ν μκ³ μμ΅λλ€.
μ΄κ²μ΄ μ°λ¦¬κ° μνλ μΈν°νμ΄μ€μ λλ€.

feedAnimals()
μ for 루νμμ animal λ³μλ any Animal
νμ
μ κ°μ§λ―λ‘ Animal νλ‘ν μ½μ λ©μλλ₯Ό κ° λ°°κ³ ν λλ¬Όλ€μ λν΄ νΈμΆν μ μμ΅λλ€.

Collection<Element>
λ‘ μ μλκ³ , associated type μΌλ‘ Element μ΄ primary associated type λΌκ³ μ μΈνκΈ° λλ¬Έμ μλμ΄ κ°λ₯ν©λλ€.

hungryAnimals μ lazily λλ eagerly νκ² κ³μ°ν μ§ μ΅μ μ κ°κΈ°λ₯Ό μνλ κ²½μ° opaque Collection μ μ¬μ©νλ©΄ λ κ°μ§ λ€λ₯Έ underlying types λ₯Ό λ°ννλ€λ μ€λ₯κ° λ°μν©λλ€.
λμ any Collection of any Animal
μ λ°ννμ¬ API κ° νΈμΆκ°μ λ€λ₯Έ νμ
μ λ°νν μ μμμ μλ €μ€μΌλ‘μ¨ μ΄ λ¬Έμ λ₯Ό ν΄κ²°ν μ μμ΅λλ€.
opaque types λ₯Ό μ¬μ©νμ¬ μΌλ°μ μΈ code λ₯Ό μμ±νλ €λ©΄ abstract type relationships μ μμ‘΄ν΄μΌ ν©λλ€. κ΄λ ¨ νλ‘ν μ½μ μ¬μ©νμ¬ μ¬λ¬ abstract types κ°μ νμν νμ κ΄κ³λ₯Ό μλ³νκ³ λ³΄μ₯νλ λ°©λ²μ λν΄ λ Όμν΄ λ³΄κ² μ΅λλ€.
Identify type relationships
μμ λ§λ Animal νλ‘ν μ½μ AniamlFeed νμ μ μλ‘μ΄ associatedtype κ³Ό λλ¬Όμκ² FeedType μ λ¨Ήλλ‘ μ§μνλ eat() λ©μλλ₯Ό μΆκ°ν κ²μ λλ€. ν₯λ―Έλ‘κ² νκΈ° μν΄μ λλ¬Όμκ² λ¨Ήμ΄λ₯Ό μ£ΌκΈ° μ μ μ μ ν νμ μ μλ¬Όμ μ¬λ°°νκ³ μννμ¬ μ¬λ£λ₯Ό μμ°νλ 볡μ‘μ±μ μΆκ°ν΄ λ³΄κ² μ΅λλ€.

λ€μμ λ κ°μ§ concrete type μ λλ€.

μμ λκ°μ§ concrete types μ λν΄ μΆμνν΄λ³΄κ² μ΅λλ€. μ΄λ₯Ό ν΅ν΄ feedAnimal() λ©μλλ₯Ό ν λ²λ§ ꡬννλ©΄ cow, chicken λ° λ€λ₯Έ μλ‘μ΄ νμ μ λλ¬Όμ λ¨ΉμΌ μ μμ΅λλ€.

feedAnimal() λ©μλλ Animal νλ‘ν μ½μ associated type μ΄ consuming postion μ μλ eat() λ©μλμ ν¨κ» μλνκΈ° λλ¬Έμ νλΌλ―Έν° νμ
μΌλ‘ some Animal
μ κ°μ§λλ‘ μ μΈν΄μ μΈλ°μ±νκ² μ΅λλ€.
μμνκΈ° μν΄μ AnimalFeed μ Crop νλ‘ν μ½μ μ μΈνκ² μ΅λλ€.

λ€μ΄μ΄κ·Έλ¨μ ν΅ν΄ 보λ―μ΄ AnimalFeed μ Crop μ¬μ΄μμ 무ν μ€μ²©κ³Ό ν¨κ» μμν κ³μ λ©λλ€.

AnimalFeed νλ‘ν μ½μμ μμνμ§λ§, Crop νλ‘ν μ½μ μ¬μ©ν΄λ λΉμ·ν μν©μ΄ λ°μν©λλ€. λ¨μ§ νλλ§ μ΄λνμ λΏμ λλ€.
μ΄λ¬ν νλ‘ν μ½μ΄ concrete types κ°μ κ΄κ³λ₯Ό μ¬λ°λ₯΄κ² λͺ¨λλ§νλμ§ μ΄ν΄λ΄ μλ€.
λλ¬Όμκ² λ¨Ήμ΄λ₯Ό μ£ΌκΈ°(eat)μ μλ¬Ό(crop)μ μ¬λ°°(harvest)ν΄μΌ μ¬λ£(animal feed)λ‘ κ°κ³΅ν μ μμ΅λλ€.

Animal μ μ€μνλ νμ μ μ»μ μ μκ³ , Animal μ associated type μΌλ‘ AnimalFeed λ₯Ό μ€μνλ FeedType μ κ°μ§κ³ μμ΅λλ€.

μ΄ νμ μ λ©μλ grow() λ₯Ό νΈμΆνλ κΈ°λ°μΌλ‘ μ¬μ©ν μ μμ΅λλ€. grow() λ©μλλ AnimalFeed μ CropType μ 리ν΄ν©λλ€.
CropType μ Crop μ μ€μνλ€λ κ²μ μκ³ μμΌλ―λ‘ harvest() λ©μλλ₯Ό νΈμΆν μ μμ΅λλ€.
μ΄λ₯Ό ν΅ν΄ μ°λ¦¬λ 무μμ λλ €λ°μ μ μμκΉμ? λ°λ‘ FeedType μ λλ€.

λΆννκ²λ μ΄κ²μ μλͺ»λ νμ μ λλ€.
eat() λ©μλλ (some Animal).FeedType
μμνμ§ (some Animal).FeedType.CropType.FeedType
μμνμ§ μμ΅λλ€.

concrete types κ°μ κ΄κ³λ₯Ό μ μνκΈ°μ νλ‘ν μ½μ μ μΈμ΄ λ무 μΌλ°μ μ΄μμ΅λλ€. μ¦, μνλ κ΄κ³λ₯Ό μ ννκ² λͺ¨λΈλ§νμ§ λͺ»νκ³ μμ΅λλ€.

κ·Έ μ΄μ λ₯Ό μ΄ν΄νκΈ° μν΄μ Hay μ Alfalfa νμ μ μ΄ν΄λ³΄κ² μ΅λλ€. hay λ₯Ό κΈ°λ₯΄λ©΄ alfalfa λ₯Ό, alfalfa λ₯Ό μννλ©΄ hay λ₯Ό μ»λ μμ λλ€. μ½λλ₯Ό 리νν λ§νκ³ μλλ° μ€μλ‘ Alfalfa μμ harvest() λ©μλμ 리ν΄κ°μ λ³κ²½νμ¬ hay λμ Scratch λ₯Ό λ°ννλ€κ³ μμν΄ λ³ΌκΉμ?
μ΄λ° μ μ°ν λ³κ²½ νμλ concrete type μ μ¬μ ν AnimalFeed λ° Crop νλ‘ν μ½μ μꡬμ¬νμ μΆ©μ‘±ν©λλ€. μλ¬Όμ μ¬λ°°νκ³ , μννλ©΄ μ°λ¦¬κ° μμν κ²κ³Ό λμΌν animal feed κ° μμλλ€λ μ°λ¦¬κ° μνλ κ·μΉμ μλ°νλλΌλ λ§μ λλ€.

AnimalFeed νλ‘ν μ½μ λ€μ μ΄ν΄λ³΄κ² μ΅λλ€. μ¬κΈ°μ μ§μ§ λ¬Έμ λ λ무 λ§μ λ³κ°μ associated type κ° μλ€λ κ²μ λλ€. μ΄λ¬ν associated Types μ€ λ κ°κ° μ€μ λ‘ λμΌν concrete type μ΄λΌλ κ²μ κΈ°λ‘ν΄μΌ ν©λλ€.(μ¦, crop μ μ¬λ°°νκ³ , μνν΄μ feed κ° λλλ° crop κ³Ό feed λ κ²°κ΅ κ°λ€. μ΄κ²μ λ³κ°μ associated type λ‘ κ°μ§κ³ μλ€.)
where
where
μ λ‘ μμ±λ same-type requirement λ₯Ό μ¬μ©νμ¬ μ΄λ¬ν associated type κ°μ κ΄κ³λ₯Ό ννν μ μμ΅λλ€.

same-type requirement μ μ€μ²©λ μ μλ associated types μ΄ μ€μ λ‘ λμΌν concrete type μ΄μ΄μΌ νλ€λ μ μ 보μ₯μ λνλ
λλ€. Self.CropType.FeedType
μ΄ Self
μ λμΌν νμ
μμ μ μΈν©λλ€. μ΄κ²μ λ€μ΄μ΄κ·Έλ¨μΌλ‘ 보κ²λλ©΄ μλμ κ°μ΅λλ€.

AnimalFeed λ₯Ό μ€μνλ concrete type μ CropType μ΄ μκ³ , μ΄κ²μ FeedType μ original AnimalFeed νμ μ concrete type μ λλ€. μ€μ²©λ ꡬ쑰 λμ λ¨μΌ μμΌλ‘ μΆμνμ΅λλ€. Crop νλ‘ν μ½μ μ΄λ¨κΉμ?

(μμ κ°μ΄ where μ μ μ¬μ©ν΄μ μκΉ μ°λ €λμλ harvest λ₯Ό ν΅ν΄μ κΈ°λ₯΄λ μλ¬Όκ³Ό λ¨Ήμ΄κ° λμΌνμ§ μμ κ²½μ°λ₯Ό λ°©μ§ν μ μμ΅λλ€.)
μ΄ λ νλ‘ν μ½μ΄ same-type requirements λ₯Ό κ°μΆμμΌλ―λ‘ feedAnimal()
λ©μλλ₯Ό λ€μ μ΄ν΄λ³Ό μ μμ΅λλ€.

μ΄μ λ λ λ€λ₯Έ associated type μ μ»λ λμ animal μ΄ κΈ°λνλ μ νν animal feed νμ μ eat() ν μ μμ΅λλ€. λ§μ§λ§μΌλ‘, μ§κΈκΉμ§ λ³Έ λͺ¨λ κ²μ νλλ‘ λ¬Άλ Animal νλ‘ν μ½μ associated type λ€μ΄μ΄κ·Έλ¨μ μ΄ν΄λ³΄κ² μ΅λλ€.

Cow μ chicken μ΄ μμ΅λλ€. κ° κ΄κ³λ₯Ό μ΄λ»κ² λͺ¨λΈλ§νλμ§ μ£Όλͺ©ν΄μ μ΄ν΄λ³΄κ² μ΅λλ€.

λ€λ₯Έ μ€μ²©λ associated types μ λλ±μ±μ μ μν μ μμμ΅λλ€. κ·Έλ¬λ©΄ μΌλ° μ½λλ νλ‘ν μ½ μꡬμ¬νμ λν΄ μ¬λ¬ νΈμΆμ ν¨κ» μ°κ²°ν λ μ΄λ¬ν κ΄κ²μ μμ‘΄ν μ μμ΅λλ€.

μ΄λ² μΈμ μμ μ°λ¦¬λ type erasure κ° μΈμ μμ νμ§, type relationships κ° λ³΄μ₯λλ context κ° μμ΄μΌ ν λλ₯Ό νꡬνμ΅λλ€.
κ·Έλ° λ€μ opaque result types μ existential types λͺ¨λμ μ¬μ©ν μ μλ primary associated types λ₯Ό μ¬μ©ν΄μ νλΆν νμ μ μ 보λ₯Ό 보쑴과 ꡬν μμΈ μ 보λ₯Ό μ¨κΈ°λ κ² μ¬μ΄μ κ· νμ μ μ§νλ λ°©λ²μ λν΄ λ Όμνμ΅λλ€.
λ§μ§λ§μΌλ‘ κ΄λ ¨ νμ μ μ§ν©μ λνλ΄λ νλ‘ν μ½ μ 체μμ same-type relationships λ₯Ό μ¬μ©νμ¬ concrete types κ°μ κ΄κ³λ₯Ό μλ³νκ³ λ³΄μ₯νλ λ°©λ²μ 보μμ΅λλ€.
