The document introduces Featherweight Scala, a calculus for a subset of Scala. It defines the grammar and evaluation rules of Featherweight Scala, including terms, types, classes, methods, and fields. It also defines type checking rules and proves they are deterministic, ensuring a type can be uniquely determined for any program.
2. 元論文
“A Core Calculus for Scala Type Checking”
- Vincent Cremet, François Garillot, Sergueï
Lenglet, Martin Odersky
Proceedings of MFCS 06, Stará Lesná, August 2006.
細かい証明はこっちを読んでね
4. val list12 = new Cons { this0 |
type Elem = Nat
val hd : Nat = zero.succ()
Featherweight Scala
val tl : this0.ListOfElem = list2
}
The List example showed how genericity can be encoded using abstract type
there is a general encoding that lets one encode all forms of parameterized type
into types with abstract members. Details are found in [1].
この論文で定義されたScalaのサブセット
trait Function extends Any { this0 |
type Dom
type Range
def apply(x : Dom): Range
}
val inc = new Function { this0 |
type Dom = Nat
type Range = Nat
def apply(x : this0.Dom): this0.Range = x.succ()
}
Fig. 3. Definition of first-class functions
Featherweight Javaに影響されてるよ
5. }
Scalaとの違い
The List example showed how genericity can be e
there is a general encoding that lets one encode all
into types with abstract members. Details are foun
自分自身を差す名前を明示する
trait Function extends Any { this0 |
type Dom
type Range コレ
def apply(x : Dom): Range
}
val inc = new Function { this0 |
type Dom = Nat
outer classへのアクセス
type Range = Nat
def apply(x : this0.Dom): this0.Range = x.succ(
6. type Elem
traitは継承できる
trait List extends Any { this0 |
type ListOfElem = List { this1 | type Elem = this0.Elem }
def isEmpty(): Boolean
def head(): this0.Elem List extends Any { this0 |
trait
def tail(): this0.ListOfElem
type Elem trait List extends Any { this0 |
} type ListOfElem = List { this1 | Elem Elem = this0.Elem }
type type
def isEmpty(): Boolean
trait Nil extends List { this0 | type ListOfElem = List { this1 | type Elem = th
def isEmpty(): Boolean = true this0.Elem
def head(): def isEmpty(): Boolean
def head(): this0.Elem =tail(): this0.ListOfElem def head(): this0.Elem
def error(”Nil.head”)
}
def tail(): this0.ListOfElem = error(”Nil.tail”) def tail(): this0.ListOfElem
} }
trait Nil extends List { this0 |
def isEmpty(): Boolean = true extends List { this0 |
trait Cons extends List { this0 | trait Nil
val hd : this0.Elem def head(): this0.Elem = error(”Nil.head”) Boolean = true
def isEmpty():
val tl : this0.ListOfElem tail(): this0.ListOfElem def head(): this0.Elem = error(”Nil.head”)
def = error(”Nil.tail”)
}
def isEmpty(): Boolean = false def tail(): this0.ListOfElem = error(”Nil.tail”)
def head(): this0.Elem = hd extends List { this0 |
trait Cons }
def tail(): this0.ListOfElem: = tl
val hd this0.Elem
trait Cons extends List { this0 |
} val tl : this0.ListOfElem
val hd : this0.Elem
def isEmpty(): Boolean = false
val tl : this0.ListOfElem
def head(): this0.Elem = hd
Fig. 2. tail(): this0.ListOfElem class hierarchyBoolean = false
def Definition of the List = tl
def isEmpty():
多重継承もできるよ
}
def head(): this0.Elem = hd
def tail(): this0.ListOfElem = tl
}
The element type of a given list is represented by the type member Elem of class
Fig. 2. Definition of the List class hierarchy
7. syntactic sugar so this is done automatically whenever a first-class function valu
in function position in an application).
As an example, Figure 4 presents a map function which applies a given
メソッドに多相性はない
function to all elements of a given list and returns a list consisting of all the
these applications. In regular Scala, this function would be defined as follows:
def map[A, B](f : A ) B, xs : List[A]): List[B] =
if (xs.isEmpty) Nil else f(x.head) :: map(f, xs.tail)
Since map is conceptually a polymorphic method, its encoding in Featherwei
makes use of a wrapper class Mapper which defines two abstract types A and
trait Mapper extends Any { this0 |
sentingAthe element types of the argument and result lists, respectively.
type
type B map method in Mapper takes as arguments a function f from type A t
The
and amap(f :xs of element Dom = A. It returns a list of element type B. An appl
def list Function { type type this0.A; type Range = this0.B },
xs : List { type Elem = this0.A }): List { type Elem = this0.B } =
would be written as follows:
map if (xs.isEmpty()) {
val result = new Nil {
val list23 ==new Mapper { type A = Nat; type B = Nat }.map(inc, li
type Elem this0.B
};
This instantiates the Mapper class with type Nat as the element type of the
result
and result{ list, and invokes the map method of the instantiation with inc and
} else
val result = new Cons {
arguments. The expression would return the encoding of the list (2, 3).
type Elem = this0.B
The example f.apply(xs.head())
val hd = shows that monomorphic functions such as inc can be first-cla
However, val tl = this0.map(f, xs.tail()) be generalized to polymorphic functions. T
};
the construction cannot
is that result
polymorphic functions like map have to be encoded using wrapper clas
wrapper classes are first-class values neither in Featherweight nor in regular
}
}
9. 文法定義
Syntax
x, y, z, ' Variable
a Value label p ::= Path
A Type label x Variable
p.a Field selection
P ::=˘ ¯ Program
x|M t S, T, U ::= Type
p.A Type selection
p.type
` ´˘ ¯ Singleton type
M, N ::= Member decl
? T '|M Type signature
valn a ` T (= t)
: ´ Field decl
defn a y : S : T (= t)? Method decl
?
typen A (= T ) ` ´˘ ¯ Type decl
traitn A extends T ' | M Class decl
s, t, u ::= Term
x Variable
t.a ` ´ Field selection
s.a t Method call
val x = new T ; t Object creation
Reduction
valn a : T = t 2 ⌃(x) ⌃`T M
BNFっぽいね
x
(red-value)
⌃ ; x.a ! ⌃ ; t ⌃ ; val x = new T ; t ! ⌃, x : M ; t
` ´ (red-new)
defn a z : S : T = t 2 ⌃(x)
(red-method)
⌃ ; x.a(y) ! ⌃ ; [y/z]t ⌃ ; t ! ⌃ 0 ; t0
(red-context)
⌃ ; e[t] ! ⌃ 0 ; e[t0 ]
10. val x = new T ; t Objec
eductionルールの読み方
valn a : T = t 2 ⌃(x)
(red-value
⌃ ; x.a ! ⌃ ; t
` ´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
11. val x = new T ; t Objec
eductionルールの読み方
valn a : T = t 2 ⌃(x)
(red-value
⌃ ; x.a ! ⌃ ; t
↑定義する記号
` ´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
12. val x = new T ; t Objec
eductionルールの読み方
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t
↑定義する記号
` ´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
13. val x = new T ; t Objec
eductionルールの読み方
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t ←ルールを適用した結果
↑定義する記号
` ´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
14. val x = new T ; t Objec
eductionルールの読み方
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t ←ルールを適用した結果
↑各変数の ↑定義する記号
`
binding
´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
15. val x = new T ; t Objec
eductionルールの読み方
↓xが...
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t ←ルールを適用した結果
↑各変数の ↑定義する記号
`
binding
´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
16. val x = new T ; t Objec
eductionルールの読み方
↓val a:T = tと定
義されている ↓xが...
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t ←ルールを適用した結果
↑各変数の ↑定義する記号
`
binding
´
efn a z : S : T = t 2 ⌃(x)
(red-method
⌃ ; x.a(y) ! ⌃ ; [y/z]t
あたりまえをちゃんと定義するよ
17. val x = new T ; t Objec
eductionルールの読み方
↓val a:T = tと定
義されている ↓xが...
valn a : T = t 2 ⌃(x) ←ルールを適用する前提
(red-value
⌃ ; x.a ! ⌃ ; t ←ルールを適用した結果
↑各変数の ↑定義する記号
`
binding
´
z : a = t = t 2 ⌃(x)
efn axがval S: T : T と定義されているとき、x.aがtに評
(red-method
⌃ ; 価される ! ⌃ ; [y/z]t
x.a(y)
あたりまえをちゃんと定義するよ
18. T '|M
Term traitn A extends = t 2 ⌃(x) Class decl
valn a : T ⌃`T x M
s, Variable
t, u ::= Term(red-value)
Field selection ⌃ ; x.a ! ⌃ ; t ⌃ ; val x = new T ; t ! ⌃, x : M ; t
x ` ´ Variable (red-new)
評価ルール
Method call
Object ` defn a z : S : T = t 2 ⌃(x) (red-method)
t.a creation
´ Field selection
s.a t ⌃ ; x.a(y) ! ⌃ ; [y/z]t Method call ⌃ ; t ! ⌃ 0 ; t0
val x = new T ; t Object creation (red-context)
⌃ ; e[t] ! ⌃ 0 ; e[t0 ]
⌃`T xM
Reduction
(red-value)
⌃ ; val x = new T ; t ! ⌃, x : M ; t
val a : T = t 2 ⌃(x) (red-new)
x) n ⌃`T x M
(red-method) Lookup (red-value)
⌃ ; x.a !⌃ ; ;t ! ⌃ ; t
⌃ t 0 0 ⌃ ; val x = new T ; t ! ⌃, x : M ; t
(red-context)
` ´ ⌃ ; e[t] !i, 0⌃; ` Ti ' Ni
8 ⌃ e[t0 ] where (red-new)
` 2
defn a z : S : T = t ´ ˘⌃(x) ¯ `U ´
⌃ ` T ' | M (red-method)
' i Ni ] M e ::= (term evaluation context)
⌃ ; x.a(y) ! ⌃ ; [y/z]t (lookup-sig) ⌃ ; thi ⌃ 0 ; t0
!
(red-context)
` ´˘ ¯ ⌃ ; e[t]e.a ⌃ 0 ; e[t0 ]
!
traitn A extends T ¯ | M 2 ⌃(y)
` ´˘ ' e.a (t)
⌃ ` T '|M ' N x.a (s, e, u)
' Ni where
`U ´ ⌃ ` y.A ' N val x = new E; t
i Ni ] M e ::= (term evaluation context)
(lookup-class) E ::= (type evaluation context)
Lookup
(lookup-sig) hi e.A
¯ e.a ` ´˘ ¯
typen A = T 2 ⌃(y) T , E, U ' | M
¯' | M 2 ⌃(y) e.a (t) `
N 8 i, ⌃ ` Ti T ' ' M
⌃ Ni where
'
` ´˘ x.a (s,¯ u) `U
e, ´ (lookup-alias)
N val ⌃ ` new ' M
⌃ ` T ' | M = y.A E;itNi ] M
x ' e ::= (term evaluation context)
(lookup-class) E ::= (type evaluation context)
(lookup-sig) hi
e.A
`
y) ` ´´ ˘ ¯ ¯
˘ e.a
term evaluation contextわかんない><
|M
T , E, U ' ' | M 2 ⌃(y)
traitn A extends T
` ´˘ ¯ e.a (t)
(lookup-alias) ⌃ ` T '|M ' N x.a (s, e, u)
⌃ ` y.A ' Fig. 5. The FSalg Calculus val x = new E; t
N : Syntax & Reduction
(lookup-class) E ::= 9 (type evaluation context)
e.A
19. (red-method)
⌃ ; x.a(y) ! ⌃ ; declarations, but we have to check that⌃ 0 ; declaration we are
collect its [y/z]t ⌃ ; t ! the t0
0 0 (red-cont
not contain the self reference '. ⌃ ; e[t] ! ⌃ ; e[t ]
ルックアップ規則
The type expansion judgment S, ` T ' M (third box of Figure 6
larations M of a type T where ' is used to represent the self reference in
M . The expansion of a class type p.A is the expansion of the type signa
Lookup
composed of its parents T and its direct members M (rule -class). T
class i, ⌃ ` Ti to Ni set S of locks in order to avoid falling into an in
8 is added ' the where
(for ' | M
⌃` T
` ´ instance if aU
˘ ¯ ` class extends itself). Rule -type is completely analo
´
' i Ni ] M e ::= (term evaluation contex
a type alias while performing the same actions on locks in order to prev
(lookup-sig) hi
expansion. ` ´ ˘
Finally, rule -signature expands a type signature: it sta
¯ e.a
traitall extends T and| M 2 merges all collected(t)
n A parents T
` ´˘ ¯ then ⌃(y)
' e.a declarations N with the di
of ` type | M ' N where (s, u)
⌃the T ' signature. The concatenation withe,rewriting of common m
x.a
eral sets of declarations is defined by M val x= M |dom(M ) dom(N ) , N , w
⌃ ` y.A ' N ] N = new E; t
(lookup-class) E ::= (type evaluation contex
dom(M ) of a sequence of declarations is the set of labels it defines an
e.A
` ´˘ ¯
M | n of declarations M to a set of labels L , E, U 'ofM of those declar
typeL A = T 2 ⌃(y) T consists | all
define T ' M L.(lookup-alias)
⌃ ` labels in
⌃ ` y.A ' M
Type and path alias expansion. We introduce here two auxiliary
alias expansion and path alias expansion that will be used when definin
型Tが定義しているメソッドを探す
judgment. The idea of the type alias expansion judgment S, ` T ' U
we take aFig. 5.TThe FSalg Calculus :alias p.A for another type T 0 , we re
type and if T is a type Syntax & Reduction
T 0 until we reach a type that is no longer a type alias. This simple behav
20. Path Typing
型付け規則
x:T 2 S, ` p.type 3 valn a : T (= t)?
(path-var)
S, `path x : T S, `path p.a : T
(path-select)
Type Assignment
S, `path p : T S, ` s : S
(path) S, ` t : T 0 S, ` T 0 <: T
S, ` p : p.type ` ´
S, ` S 3 defn a x : T : U (= u)?
`´
S, ` s.a t : U
(method)
S, ` t : S t is not a path S, , x : T ` t : S x 62 fn(S)
S, ` S 3 valn a : T (= u)? S, ` T ' Mc S, ` T wf
(select) (new)
S, ` t.a : T S, ` val x = new T ; t : S
Expansion
` ´˘ ¯
S, ` p.type 3 traitn A extends T ' | M
` ´˘ ¯ S, ` p.type 3 typen A = T
{n} [ S, ` T ' | M ' N n 62 S {n} [ S, ` T ' M n 62 S
S, 細かいサブルールに分かれているよ
` p.A N '
( -class)
S, ` p.A M '
( -type)
8 i, S, ` Ti ' Ni
` ´˘ ¯ `U ´
S, ` T '|M ' i Ni ] M
21. 各記号の意味
The first two boxes of Figure 6 pr
judgment S, ` t : T always ass
path 式を記録する receives the type p.t
p always
S: locked declaration。無限ループを防ぐために、使った
ssigned a bound T (rule path). A
Γ: 型環境
and to項 establish, using the member
t:
?
declaration valn a : T (= u) ; in th
T: 型
lect). Note that this rule is only ap
Sはちょっと特殊かも
back to rule path. Rule method all
22. パスの型付け
Path Typing
x:T 2 S, ` p.type 3 valn a : T (= t)?
(path-var)
S, `path x : T S, `path p.a : T
(path-select)
Type Assignment
S, `path p : T S, ` s : S
(path) S, ` t : T 0 S, ` T 0 <: T
S, ` p : p.type ` ´
S, ` S 3 defn a x : T : U (= u)?
`´
S, ` s.a t : U
パスはA.B.T みたいな型のことだよ (method)
S, ` t : S t is not a path S, , x : T ` t : S x 62 fn(S)
S, ` S 3 valn a : T (= u)? S, ` T ' Mc S, ` T wf
(select) (new)
23. ( -type)
(S, S,` T`wf) ' N
p.A? S, x.A ` `T ´ ˘' | M ¯ wf'
S, , ' : ` p.A ' M
?
(wf-x-type)
( -class) ` ´˘ ¯
S, ` type A (= T ) wfx S, ` traitn A extends T ' | M wfx
Path Typing n 8 i, S, ` Ti ' (wf-x-class)
Ni
メンバシップ関係
` ´˘ ¯ `U ´
S, ` T ' | M ' i Ni ] M
x:T 2 S, ` p.type 3 valn a : wf ( ? -signature)
S, ` S, T T (= t)
(path-var)
S,S, `path xwf
`T :T S does not`path p.a singleton types
S, contain : T
0 0 ? ` 0 (path-select)?
0
´
(S, ` t : T S, ` T <: T ) S, , x : S ` t : T S, ` T <: T
Membership valn a : T (= t)? wfx ` ´
S, ` S, ` defn a x : S : T (= t)? wfx
Type Assignment (wf-x-field) (wf-x-method)
S, ` p ' q S, `path q : T T is not a singleton type
(p) [ S, S,` T ' p : 8i, S, (p) 6✓ iS ' Ni
`path M T `T S, `` T wf' M s : S' 2 fn(Mi )
S, M S, ` ' /
S, 3 [p/']Mi (path) j), S, ` (Ni+jt, :M ) ⌧ Ni3 MiT 0 <: T (3-other)
S, S, p.type ` T wf
` ` p : p.type 8 (i,
` ´˘ ¯S, ` S, ` `S, ` (wf-x-signature)
T0 T ´
(3-singleton) ' | M wf' 3 defn a x : T : U (= u)?
S, ` T S, ` S
`´
S, ` s.a t : U
Path Alias Expansion (method)
S, `6. : The FSalg Calculus : Type Assignment,xExpansion &xMembership
Fig. t S t is not a path S, , : T ` t : S 62 fn(S)
S, ` `path p : q.type u)?
S, S 3 valn a : T (= S, ` T ' Mc
S, `path p :`TT wf
S,
(p) [ S, ` q ' q 0 (p) 6✓ S (select) T is not a singleton type (new)
S, ` t.a : 0T ('-Step) S, ` val x = new T ; t : S ('-Refl)
S, `p'q S, `p'p
Expansion 10
Fig. 7. The FS alg Calculus´ :˘Well-Formedness and Path Alias Expansion
` ¯
S, ` p.type 3 traitn A extends T ' | M
` ´˘ ¯ S, ` p.type 3 typen A = T
{n} [ S, ` T ' | M ' N n 62 S {n} [ S, ` T ' M n 62 S
( -type)
S, ` p.A ' N S, ` p.A ' M
( -class)
8 i, S, ` Ti ' Ni
` ´˘ ¯ `U ´
S, ` T '|M ' i Ni ] M
( -signature)
11
24. Well-Formedness
Well-Formedness
` ´˘ ¯ ` ´˘ ¯
S, `path p : T (p) 6✓ S S, , ' : T ' | M ` T ' | M wf'
(p) [ S, ` T wf ` ´˘ ¯
S, ` T ' | M wf
S, ` p.type wf (wf-signature)
(wf-singleton)
` ´˘ ¯ S, ` p.type 3 typen A (= T )?
S, ` p.type 3 traitn A extends T ' | M “ ”?
S, ` p.A wf {n} [ S, ` T wf n 62 S
(wf-type)
(wf-class) S, ` p.A wf
MemberWell-Formedness
?
` ´˘ ¯
(S, ` T wf) S, , ' : x.A ` T ' | M wf'
?
(wf-x-type) ` ´˘ ¯
S, ` typen A (= T ) wfx S, ` traitn A extends T ' | M wfx
(wf-x-class)
型Tをnewする前提。目的がわからない><
S, ` S, T wf
S, ` T wf S does not contain singleton types
? ` ´?
(S, ` t : T0 S, ` T 0 <: T ) S, , x : S ` t : T 0 0
S, ` T <: T
? ` ´ ?
25. Well-Formdness for
Well-Formedness
` ´˘ ¯ ` ´˘ ¯
S, `path p : T (p) 6✓ S S, , ' : T ' | M ` T ' | M wf'
(p) [ S, ` T wf ` ´˘ ¯
S, ` T ' | M wf
S, ` p.type wf (wf-signature)
member
(wf-singleton)
` ´˘ ¯ S, ` p.type 3 typen A (= T )?
S, ` p.type 3 traitn A extends T ' | M “ ”?
S, ` p.A wf {n} [ S, ` T wf n 62 S
(wf-type)
(wf-class) S, ` p.A wf
MemberWell-Formedness
` ´˘ ¯
(S, ` T wf)? S, , ' : x.A ` T ' | M wf'
(wf-x-type) ` ´˘ ¯
S, ` typen A (= T )? wfx S, ` traitn A extends T ' | M wfx
(wf-x-class)
S, ` S, T wf
S, ` T wf S does not contain singleton types
? ` ´?
(S, ` t : T0 S, ` T 0 <: T ) S, , x : S ` t : T 0 S, ` T 0 <: T
` ´
S, ` valn a : T (= t)? wfx S, ` defn a x : S : T (= t)? wfx
(wf-x-field) (wf-x-method)
8i, S, ` Ti ' Ni S, ` M wf'
S, ` T wf 8 (i, j), S, ` (Ni+j , M ) ⌧ Ni
` ´˘ ¯ (wf-x-signature)
S, ` T ' | M wf'
Path Alias Expansion
S, `path p : q.type S, `path p : T
(p) [ S, ` q ' q 0 (p) 6✓ S T is not a singleton type
('-Step) ('-Refl)
S, ` p ' q0 S, `p'p
こっちも意味がわからない><
Fig. 7. The FSalg Calculus : Well-Formedness and Path Alias Expansion
26. ` ´˘ ¯
S, ` p.type 3 typen A = T S, ` p.type 3 traitn A extends T ' | M
{n} [ S, ` T ' U n 62 S S, ` p.A ' p.A
('-type)
S, ` p.A ' U ('-class)
S,
S,
サブタイプ
` p.type 3 typen A
` p.A ' p.A
('-abstype)
S,
S,
` ´˘ ¯ ` ´˘
` T '|M ' T '|M
¯
('-signature)
` p.type ' p.type ('-singleton)
Algorithmic Subtyping
S, ` T ' T0 S, ` U ' U 0 A 6= A0 {n} [ S, ` Ti <: p0 .A0 ´ ˘ n 2 S
` / ¯
S, `⇤ T 0 <: U 0 S, ` p.type 3 traitn A extends T ' | M
S, ` T <: U S, `⇤ p.A <: p0 .A0
(<:-unalias) (<:-class)
S, ` p ' p0 S, ` q ' p0
S, `⇤ p.type <: q.type S, ` Ti <: p.A
(<:-singleton-right) ` ´˘ ¯ (<:-sig-left)
S, `⇤ T ' | M <: p.A
U is not a singleton type
S, `p'q S, `path q : T S, ` T <: U
S, `⇤ p.type <: U
T is not a singleton type
(<:-singleton-left)
8i, S, ` T <: Ti S, ` T ' N
S, ` p ' p0 S, ` q ' p0 dom(M ) ✓ dom(N ) S, ` N ⌧ M
` ´˘ ¯
S, `⇤ p.A <: q.A S, `⇤ T <: T ' | M
(<:-paths) (<:-sig-right)
Member Subtyping
S,
エイリアスのせいでややこしい><S, ` T <: T 0
` valn a : T (= t)? <: valm a : T 0 (= t0 )
?
S, ` typen A = T <: typen A (= T )?
(<:-member-type)
(<:-member-field)
` ´˘ ¯ ` ´˘ ¯
S, ` traitn A extends T ' | M <: traitn A extends T ' | M (<:-member-class)
27. S, `⇤ p.type <: q.type S, ` Ti <: p.A
(<:-singleton-right) ` ´˘ ¯ (<:-sig-left)
S, `⇤ T ' | M <: p.A
U is not a singleton type
S, `p'q S, `path q : T S, ` T <: U
メンバ間のサブタイプ関係
S,
S,
` p ' p0
`⇤ p.type <: U
S,
(<:-singleton-left)
` q ' p0
T is not a singleton type
8i, S, ` T <: Ti
dom(M ) ✓ dom(N )
S, ` T ' N
S, ` N ⌧ M
` ´˘ ¯
S, `⇤ p.A <: q.A S, `⇤ T <: T ' | M
(<:-paths) (<:-sig-right)
Member Subtyping
S, ` T <: T 0 S, ` typen A = T <: typen A (= T )?
?
S, ` valn a : T (= t)? <: valm a : T 0 (= t0 ) (<:-member-type)
(<:-member-field)
` ´˘ ¯ ` ´˘ ¯
S, ` traitn A extends T ' | M <: traitn A extends T ' | M (<:-member-class)
S, ` S 0 <: S S, ` T <: T 0
` ´ ` ´ (<:-member-method)
S, ?
` defn a x : S : T (= t) <: defm a x : S 0 : T 0 (= t0 )?
Fig. 8. The FSalg Calculus : Subtyping
12
いっぱいある><