共通フィールドの表現方法 (2)
type TState interface {
isTState()
}
type T[S TState] struct {
Common1 int
Common2 int
State
S
}
type T1 struct{}
type T2 struct {
Field1 int
}
type T3 struct {
Field1 int
Field2 int
}
53
ジェネリクス以降の潮流 (2)
● proposal: spec: sum types based on
general interfaces #57644
○ interface { X | Y } の | を型パラメータ以外でも使え
るようにする
○ 2023/1/6 に起票
■ 2026/11/17 現在 Open
62
Slide 63
Slide 63 text
ジェネリクス以降の潮流 (3)
● proposal: spec: define sum types as an
extension of interfaces #80607
○ sum_interfaceというキーワードでsealed interface
を直和型として定義できるようにする
○ likely declineでcloseされた
■ 網羅性チェックがあると、直和型のメンバーを追加すること
が非互換変更になる
63