WWDC 22 Embrace Swift generics 의 후속 조사

개념


정의


Static type

Dynamic type

Concrete type

Abstract type

type(of:)


protocol Test {
    init()
    func test()
}

struct SomeTest: Test {
    func test() {}
		
		static func testA() {}
}

var value: Test = SomeTest()

type(of:value).init() // dynamic type 을 반환한다는 점, 

// Test.init() 이건 안됨 Test 는 existential type 으로 직접 인스턴스를 생성할 수 없음.

// type(of:value).testA() 이것도 안됨. Value of type 'Test.Type' has no member 'testA'