OLD | NEW |
1 \documentclass[fleqn]{article} | 1 \documentclass[fleqn, draft]{article} |
2 \usepackage{proof, amsmath} | 2 \usepackage{proof, amsmath, amssymb, ifthen} |
| 3 \input{macros.tex} |
3 | 4 |
4 % types | 5 % types |
5 \newcommand{\Arrow}[2]{#1 \rightarrow #2} | 6 \newcommand{\Arrow}[3][-]{#2 \overset{#1}{\rightarrow} #3} |
6 \newcommand{\Bool}{\mathbf{bool}} | 7 \newcommand{\Bool}{\mathbf{bool}} |
7 \newcommand{\Bottom}{\mathbf{bottom}} | 8 \newcommand{\Bottom}{\mathbf{bottom}} |
8 \newcommand{\Dynamic}{\mathbf{dynamic}} | 9 \newcommand{\Dynamic}{\mathbf{dynamic}} |
9 \newcommand{\Null}{\mathbf{Null}} | 10 \newcommand{\Null}{\mathbf{Null}} |
10 \newcommand{\Num}{\mathbf{num}} | 11 \newcommand{\Num}{\mathbf{num}} |
11 \newcommand{\Object}{\mathbf{Object}} | 12 \newcommand{\Object}{\mathbf{Object}} |
12 \newcommand{\TApp}[2]{#1\mathrm{<}#2\mathrm{>}} | 13 \newcommand{\TApp}[2]{#1\mathrm{<}#2\mathrm{>}} |
13 \newcommand{\Type}{\mathbf{Type}} | 14 \newcommand{\Type}{\mathbf{Type}} |
14 | 15 |
15 % expressions | 16 % expressions |
16 \newcommand{\eapp}[2]{#1(#2)} | 17 \newcommand{\eassign}[2]{#1 = #2} |
17 \newcommand{\eas}[2]{#1\ \mathbf{as}\ #2} | 18 \newcommand{\eas}[2]{#1\ \mathbf{as}\ #2} |
18 \newcommand{\eassign}[2]{#1 = #2} | 19 \newcommand{\echeck}[2]{\kwop{check}(#1, #2)} |
| 20 \newcommand{\ecall}[2]{#1(#2)} |
| 21 \newcommand{\edcall}[2]{\kwop{dcall}(#1, #2)} |
| 22 \newcommand{\edload}[2]{\kwop{dload}(#1, #2)} |
19 \newcommand{\eff}{\mathrm{ff}} | 23 \newcommand{\eff}{\mathrm{ff}} |
20 \newcommand{\eis}[2]{#1\ \mathbf{is}\ #2} | 24 \newcommand{\eis}[2]{#1\ \mathbf{is}\ #2} |
21 \newcommand{\elambda}[2]{(#1) \Rightarrow #2} | 25 \newcommand{\elambda}[3]{(#1):#2 \Rightarrow #3} |
| 26 \newcommand{\eload}[2]{#1.#2} |
| 27 \newcommand{\eset}[3]{\eassign{#1.#2}{#3}} |
22 \newcommand{\enew}[3]{\mathbf{new}\,\TApp{#1}{#2}(#3)} | 28 \newcommand{\enew}[3]{\mathbf{new}\,\TApp{#1}{#2}(#3)} |
23 \newcommand{\enull}{\mathbf{null}} | 29 \newcommand{\enull}{\mathbf{null}} |
24 \newcommand{\eprimapp}[2]{\eapp{#1}{#2}} | 30 \newcommand{\eprim}{\kwop{op}} |
25 \newcommand{\eproj}[2]{#1.#2} | 31 \newcommand{\eprimapp}[2]{\ecall{#1}{#2}} |
26 \newcommand{\esend}[3]{\eapp{\eproj{#1}{#2}}{#3}} | 32 \newcommand{\esend}[3]{\ecall{\eload{#1}{#2}}{#3}} |
27 \newcommand{\esuper}{\mathbf{super}} | 33 \newcommand{\esuper}{\mathbf{super}} |
28 \newcommand{\ethis}{\mathbf{this}} | 34 \newcommand{\ethis}{\mathbf{this}} |
| 35 \newcommand{\ethrow}{\mathbf{throw}} |
29 \newcommand{\ett}{\mathrm{tt}} | 36 \newcommand{\ett}{\mathrm{tt}} |
30 | 37 |
31 % keywords | 38 % keywords |
32 \newcommand{\kwclass}{\mathbf{class}} | 39 \newcommand{\kwclass}{\kw{class}} |
33 \newcommand{\kwextends}{\mathbf{extends}} | 40 \newcommand{\kwextends}{\kw{extends}} |
34 \newcommand{\kwelse}{\mathbf{else}} | 41 \newcommand{\kwelse}{\kw{else}} |
35 \newcommand{\kwif}{\mathbf{if}} | 42 \newcommand{\kwfun}{\kw{fun}} |
36 \newcommand{\kwin}{\mathbf{in}} | 43 \newcommand{\kwif}{\kw{if}} |
37 \newcommand{\kwlet}{\mathbf{let}} | 44 \newcommand{\kwin}{\kw{in}} |
38 \newcommand{\kwreturn}{\mathbf{return}} | 45 \newcommand{\kwlet}{\kw{let}} |
39 \newcommand{\kwthen}{\mathbf{then}} | 46 \newcommand{\kwreturn}{\kw{return}} |
40 \newcommand{\kwvar}{\mathbf{var}} | 47 \newcommand{\kwthen}{\kw{then}} |
| 48 \newcommand{\kwvar}{\kw{var}} |
41 | 49 |
42 % declarations | 50 % declarations |
43 \newcommand{\dclass}[3]{\kwclass\ #1\ \kwextends\ #2\ \{#3\}} | 51 \newcommand{\dclass}[3]{\kwclass\ #1\ \kwextends\ #2\ \{#3\}} |
44 \newcommand{\dfun}[4]{#1\ #2(#3)\ #4} | 52 \newcommand{\dfun}[4]{#2(#3):#1 = #4} |
45 \newcommand{\dvar}[2]{\kwvar\ #1\ =\ #2} | 53 \newcommand{\dvar}[2]{\kwvar\ #1\ =\ #2} |
46 | 54 |
| 55 |
| 56 \newcommand{\fieldDecl}[2]{\kwvar\ #1 : #2} |
| 57 \newcommand{\methodDecl}[2]{\kwfun\ #1 : #2} |
| 58 |
47 % statements | 59 % statements |
48 \newcommand{\sifthenelse}[3]{\kwif\ (#1)\ \kwthen\ #2\ \kwelse\ #3} | 60 \newcommand{\sifthenelse}[3]{\kwif\ (#1)\ \kwthen\ #2\ \kwelse\ #3} |
49 \newcommand{\sreturn}[1]{\kwreturn\ #1} | 61 \newcommand{\sreturn}[1]{\kwreturn\ #1} |
50 | 62 |
51 % programs | 63 % programs |
52 \newcommand{\program}[2]{\kwlet\ #1\ \kwin\ #2} | 64 \newcommand{\program}[2]{\kwlet\ #1\ \kwin\ #2} |
53 | 65 |
54 % relational operators | 66 % relational operators |
55 \newcommand{\sub}{\mathop{<:}} | 67 \newcommand{\sub}{\mathbin{<:}} |
56 | 68 |
57 % utilities | 69 % utilities |
58 \newcommand{\many}[1]{\overrightarrow{#1}} | 70 \newcommand{\many}[1]{\overrightarrow{#1}} |
59 \newcommand{\alt}{\ \mathop{|}\ } | 71 \newcommand{\alt}{\ \mathop{|}\ } |
| 72 \newcommand{\opt}[1]{[#1]} |
60 | 73 |
61 % inference rules | 74 % inference rules |
62 \newcommand{\axiom}[1]{\infer{#1}{}} | 75 \newcommand{\infrulem}[3][]{ |
63 \newcommand{\infrule}[2]{\infer{#2}{#1}} | 76 \begin{array}{c@{\ }c} |
64 | 77 \begin{array}{cccc} |
65 % relations | 78 #2 \vspace{-2mm} |
| 79 \end{array} \\ |
| 80 \hrulefill & #1 \\ |
| 81 \begin{array}{l} |
| 82 #3 |
| 83 \end{array} |
| 84 \end{array} |
| 85 } |
| 86 |
| 87 \newcommand{\axiomm}[2][]{ |
| 88 \begin{array}{cc} |
| 89 \hrulefill & #1 \\ |
| 90 \begin{array}{c} |
| 91 #2 |
| 92 \end{array} |
| 93 \end{array} |
| 94 } |
| 95 |
| 96 \newcommand{\infrule}[3][]{ |
| 97 \[ |
| 98 \infrulem[#1]{#2}{#3} |
| 99 \] |
| 100 } |
| 101 |
| 102 \newcommand{\axiom}[2][]{ |
| 103 \[ |
| 104 \axiomm[#1]{#2} |
| 105 \] |
| 106 } |
| 107 |
| 108 % judgements and relations |
| 109 \newboolean{show_translation} |
| 110 \setboolean{show_translation}{false} |
| 111 \newcommand{\iftrans}[1]{\ifthenelse{\boolean{show_translation}}{#1}{}} |
| 112 |
| 113 \newcommand{\blockOk}[4]{#1 \vdash #2 \col #3\iftrans{\, \Uparrow\, #4}} |
| 114 \newcommand{\declOk}[5][]{#2 \vdash_{#1} #3 \, \Uparrow\, \iftrans{#4\, :\,} #5} |
66 \newcommand{\extends}[4][:]{#2[#3\ #1\ #4]} | 115 \newcommand{\extends}[4][:]{#2[#3\ #1\ #4]} |
| 116 \newcommand{\fieldLookup}[4]{#1 \vdash #2.#3\, \leadsto_f\, #4} |
| 117 \newcommand{\methodLookup}[4]{#1 \vdash #2.#3\, \leadsto_m\, #4} |
| 118 \newcommand{\hastype}[3]{#1 \vdash #2 \, : \, #3} |
| 119 \newcommand{\stmtOk}[5]{#1 \vdash #2 \, : \, #3\, \Uparrow \iftrans{#4\, :\,} #5
} |
67 \newcommand{\subst}[2]{[#1/#2]} | 120 \newcommand{\subst}[2]{[#1/#2]} |
68 \newcommand{\subtypeOf}[3]{#1 \vdash\ #2 \sub\ #3} | 121 \newcommand{\subtypeOfOpt}[5][?]{#2 \vdash\ #3 \sub^{#1} #4\, \Uparrow\, #5} |
| 122 \newcommand{\subtypeOf}[4][]{#2 \vdash\ #3 \sub^{#1} #4} |
| 123 \newcommand{\yieldsOk}[5]{#1 \vdash #2 \, : \, #3\, \Uparrow\, \iftrans{#4\, :\,
} #5} |
| 124 |
| 125 |
| 126 \newcommand{\sstext}[2]{\ifthenelse{\boolean{show_translation}}{#2}{#1}} |
| 127 |
| 128 |
69 | 129 |
70 \title{Dart strong mode definition} | 130 \title{Dart strong mode definition} |
71 | 131 |
72 \begin{document} | 132 \begin{document} |
73 | 133 |
| 134 \textbf{\large PRELIMINARY DRAFT} |
| 135 |
74 \section*{Syntax} | 136 \section*{Syntax} |
75 | 137 |
76 | 138 |
| 139 Terms and types. Note that we allow types to be optional in certain positions |
| 140 (currently function arguments and return types, and on variable declarations). |
| 141 Implicitly these are either inferred or filled in with dynamic. |
| 142 |
| 143 There are explicit terms for dynamic calls and loads, and for dynamic type |
| 144 checks. |
| 145 |
| 146 Fields can only be read or set within a method via a reference to this, so no |
| 147 dynamic set operation is required (essentially dynamic set becomes a dynamic |
| 148 call to a setter). This just simplifies the presentation a bit. Methods may be |
| 149 externally loaded from the object (either to call them, or to pass them as |
| 150 closurized functions). |
| 151 |
77 \[ | 152 \[ |
78 \begin{array}{lcl} | 153 \begin{array}{lcl} |
79 \text{Type identifiers} & ::= & C, G, T, S, \ldots \\ | 154 \text{Type identifiers} & ::= & C, G, T, S, \ldots \\ |
80 % | 155 % |
| 156 \text{Arrow kind ($k$)} & ::= & +, -\\ |
| 157 % |
81 \text{Types $\tau, \sigma$} & ::= & | 158 \text{Types $\tau, \sigma$} & ::= & |
82 T \alt \Dynamic \alt \Object \alt \Null \alt \Type \alt \Num \alt \Bool \\ && | 159 T \alt \Dynamic \alt \Object \alt \Null \alt \Type \alt \Num \\ && |
83 \alt \Arrow{\many{\tau}}{\sigma} \alt \TApp{C}{\many{\tau}} \\ | 160 \alt \Bool |
| 161 \alt \Arrow[k]{\many{\tau}}{\sigma} \alt \TApp{C}{\many{\tau}} \\ |
| 162 % |
| 163 \text{Optional type ($[\tau]$)} & ::= & \_ \alt \tau \\ |
84 % | 164 % |
85 \text{Term identifiers} & ::= & a, b, x, y, m, n, \ldots \\ | 165 \text{Term identifiers} & ::= & a, b, x, y, m, n, \ldots \\ |
86 % | 166 % |
87 \text{Primops ($\phi$)} & ::= & \mathrm{+}, \mathrm{-} \ldots \mathrm{||} \ldots
\\ | 167 \text{Primops ($\phi$)} & ::= & \mathrm{+}, \mathrm{-} \ldots \mathrm{||} \ldots
\\ |
88 % | 168 % |
89 \text{lhs ($l$)} & ::= & x \alt \eproj{e}{m} \\ | |
90 % | |
91 \text{Expressions $e$} & ::= & | 169 \text{Expressions $e$} & ::= & |
92 x \alt i \alt \ett \alt \eff \alt \enull \alt \ethis \alt \esuper | 170 x \alt i \alt \ett \alt \eff \alt \enull \alt \ethis \\&& |
93 \alt \elambda{\many{x:\tau}}{e} \alt \enew{C}{\many{\tau}}{\many{e}} \\&& | 171 \alt \elambda{\many{x:\opt{\tau}}}{\opt{\sigma}}{e} |
94 \alt \eprimapp{\phi}{\many{e}} \alt \eapp{e}{\many{e}} | 172 \alt \enew{C}{\many{\tau}}{} \\&& |
95 \alt \eproj{e}{m} \alt \eassign{l}{e} \\&& | 173 \alt \eprimapp{\eprim}{\many{e}} \alt \ecall{e}{\many{e}} |
96 \alt \eas{e}{\tau} \alt \eis{e}{\tau} \\ | 174 \alt \edcall{e}{\many{e}} \\&& |
| 175 \alt \eload{e}{m} \alt \edload{e}{m} \alt \eload{\ethis}{x} \\&& |
| 176 \alt \eassign{x}{e} \alt \eset{\ethis}{x}{e} \\&& |
| 177 \alt \ethrow \alt \eas{e}{\tau} \alt \eis{e}{\tau} \alt \echeck{e}{\tau}\\ |
97 % | 178 % |
98 \text{Declaration ($\mathit{vd}$)} & ::= & | 179 \text{Declaration ($\mathit{vd}$)} & ::= & |
99 \dvar{x}{e} \alt \dvar{x:\tau}{e} \alt \dfun{\tau}{f}{\many{x:\tau}}{b} \\ | 180 \dvar{x:\opt{\tau}}{e} \alt \dfun{\tau}{f}{\many{x:\tau}}{s} \\ |
100 % | 181 % |
101 \text{Statements ($s$)} & ::= & \mathit{vd} \alt e \alt \sifthenelse{e}{b_1}{b_2
} | 182 \text{Statements ($s$)} & ::= & \mathit{vd} \alt e \alt \sifthenelse{e}{s_1}{s_2
} |
102 \alt \sreturn{e} \alt s;s \\ | 183 \alt \sreturn{e} \alt s;s \\ |
103 % | 184 % |
104 \text{Blocks ($b$)} & ::= & \{s;\} \\ | |
105 % | |
106 \text{Class decl ($\mathit{cd}$)} & ::= & \dclass{\TApp{C}{\many{T}}}{\TApp{G}{\
many{S}}}{\many{\mathit{vd}}} \\ | 185 \text{Class decl ($\mathit{cd}$)} & ::= & \dclass{\TApp{C}{\many{T}}}{\TApp{G}{\
many{S}}}{\many{\mathit{vd}}} \\ |
107 % | 186 % |
108 \text{Toplevel decl ($\mathit{td}$)} & ::= & \mathit{vd} \alt \mathit{cd}\\ | 187 \text{Toplevel decl ($\mathit{td}$)} & ::= & \mathit{vd} \alt \mathit{cd}\\ |
109 % | 188 % |
110 \text{Program ($P$)} & ::= & \program{\many{\mathit{td}}}{b} | 189 \text{Program ($P$)} & ::= & \program{\many{\mathit{td}}}{s} |
111 \end{array} | 190 \end{array} |
112 \] | 191 \] |
113 | 192 |
114 | 193 |
| 194 Type contexts map type variables to their bounds. |
| 195 |
| 196 Class signatures describe the methods and fields in an object, along with the |
| 197 super class of the class. There are no static methods or fields. |
| 198 |
| 199 The class hierararchy records the classes with their signatures. |
| 200 |
| 201 The term context maps term variables to their types. I also abuse notation and |
| 202 allow for the attachment of an optional type to term contexts as follows: |
| 203 $\Gamma_\sigma$ refers to a term context within the body of a method whose class |
| 204 type is $\sigma$. |
115 | 205 |
116 \[ | 206 \[ |
117 \begin{array}{lcl} | 207 \begin{array}{lcl} |
118 \text{Class signature ($\mathit{Sig}$)} & ::= & \dclass{\TApp{C}{\many{T}}}{\TA
pp{G}{\many{S}}}{\many{x:\tau}} \\ | 208 \text{Type context ($\Delta$)} & ::= & \epsilon \alt \Delta, T \sub \tau \\ |
119 \text{Type context ($\Delta$)} & ::= & \epsilon \alt \Delta, X \sub \tau \\ | 209 \text{Class element ($\mathit{ce}$)} & ::= & |
120 \text{Class hierarchy ($\Phi$)} & ::= & \epsilon \alt \Phi, C\ :\ \mathit{Sig} | 210 \fieldDecl{x}{\tau} \alt \methodDecl{f}{\tau} \\ |
| 211 \text{Class signature ($\mathit{Sig}$)} & ::= & |
| 212 \dclass{\TApp{C}{\many{T}}}{\TApp{G}{\many{S}}}{\many{\mathit{ce}}} \\ |
| 213 \text{Class hierarchy ($\Phi$)} & ::= & \epsilon \alt \Phi, C\ :\ \mathit{Sig}
\\ |
| 214 \text{Term context ($\Gamma$)} & ::= & \epsilon \alt \Gamma, x\ :\ \tau |
121 \end{array} | 215 \end{array} |
122 \] | 216 \] |
123 | 217 |
124 | 218 |
125 \section*{Subtyping} | 219 \section*{Subtyping} |
126 \[ | 220 |
127 \begin{array}{ccc} | 221 \subsection*{Variant Subtyping} |
128 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Dynamic}} & | 222 |
129 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Object}} \\\\ | 223 We include a special kind of covariant function space to model certain dart |
130 % | 224 idioms. An arrow type decorated with a positive variance annotation ($+$) |
131 \axiom{\subtypeOf{\Phi, \Delta}{\Bottom}{\tau}} & | 225 treats $\Dynamic$ in its argument list covariantly: or equivalently, it treats |
132 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\tau}} \\\\ | 226 $\Dynamic$ as bottom. This variant subtyping relation captures this special |
133 % | 227 treatment of dynamic. |
134 \infrule{\Delta = \extends[\sub]{\Delta'}{S}{\sigma} & | 228 |
| 229 \axiom{\subtypeOf[+]{\Phi, \Delta}{\Dynamic}{\tau}} |
| 230 |
| 231 \infrule{\subtypeOf{\Phi, \Delta}{\sigma}{\tau} \quad \sigma \neq \Dynamic} |
| 232 {\subtypeOf[+]{\Phi, \Delta}{\sigma}{\tau}} |
| 233 |
| 234 \infrule{\subtypeOf{\Phi, \Delta}{\sigma}{\tau}} |
| 235 {\subtypeOf[-]{\Phi, \Delta}{\sigma}{\tau}} |
| 236 |
| 237 \subsection*{Invariant Subtyping} |
| 238 |
| 239 Regular subtyping is defined in a fairly standard way, except that generics are |
| 240 uniformly covariant, and that function argument types fall into the variant |
| 241 subtyping relation defined above. |
| 242 |
| 243 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Dynamic}} |
| 244 |
| 245 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Object}} |
| 246 |
| 247 \axiom{\subtypeOf{\Phi, \Delta}{\Bottom}{\tau}} |
| 248 |
| 249 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\tau}} |
| 250 |
| 251 \infrule{(S\, :\, \sigma) \in \Delta \quad |
135 \subtypeOf{\Phi, \Delta}{\sigma}{\tau}} | 252 \subtypeOf{\Phi, \Delta}{\sigma}{\tau}} |
136 {\subtypeOf{\Phi, \Delta}{S}{\tau}} \\\\ | 253 {\subtypeOf{\Phi, \Delta}{S}{\tau}} |
137 % | 254 |
138 \infrule{\subtypeOf{\Phi, \Delta}{\sigma_i}{\tau_i} & i \in 0, \ldots, n & | 255 \infrule{\subtypeOf[k_1]{\Phi, \Delta}{\sigma_i}{\tau_i} \quad i \in 0, \ldots,
n \quad\quad |
139 \subtypeOf{\Phi, \Delta}{\tau_r}{\sigma_r}} | 256 \subtypeOf{\Phi, \Delta}{\tau_r}{\sigma_r} \\ |
| 257 \quad (k_0 = \mbox{-}) \lor (k_1 = \mbox{+}) |
| 258 } |
140 {\subtypeOf{\Phi, \Delta} | 259 {\subtypeOf{\Phi, \Delta} |
141 {\Arrow{\tau_0, \ldots, \tau_n}{\tau_r}} | 260 {\Arrow[k_0]{\tau_0, \ldots, \tau_n}{\tau_r}} |
142 {\Arrow{\sigma_0, \ldots, \sigma_n}{\sigma_r}}} \\\\ | 261 {\Arrow[k_1]{\sigma_0, \ldots, \sigma_n}{\sigma_r}}} |
143 % | 262 |
144 \infrule{\subtypeOf{\Phi, \Delta}{\tau_i}{\sigma_i} & i \in 0, \ldots, n} | 263 \infrule{\subtypeOf{\Phi, \Delta}{\tau_i}{\sigma_i} & i \in 0, \ldots, n} |
145 {\subtypeOf{\Phi, \Delta} | 264 {\subtypeOf{\Phi, \Delta} |
146 {\TApp{C}{\tau_0, \ldots, \tau_n}} | 265 {\TApp{C}{\tau_0, \ldots, \tau_n}} |
147 {\TApp{C}{\sigma_0, \ldots, \sigma_n}}}\\\\ | 266 {\TApp{C}{\sigma_0, \ldots, \sigma_n}}} |
148 % | 267 |
149 \infrule{\Phi = \extends{\Phi'}{C}{\dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\
upsilon_0, \ldots, \upsilon_k}}{\ldots}} \\ | 268 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u
psilon_k}}{\ldots}) \in \Phi \\ |
150 \subtypeOf{\Phi, \Delta}{\subst{\tau_0, \ldots, \tau_n}{T_0, \ldots, T_
n}{\TApp{C'}{\upsilon_0, \ldots, \upsilon_k}}}{\TApp{G}{\sigma_0, \ldots, \sigma
_m}}} | 269 \subtypeOf{\Phi, \Delta}{\subst{\tau_0, \ldots, \tau_n}{T_0, \ldots, T_
n}{\TApp{C'}{\upsilon_0, \ldots, \upsilon_k}}}{\TApp{G}{\sigma_0, \ldots, \sigma
_m}}} |
151 {\subtypeOf{\Phi, \Delta} | 270 {\subtypeOf{\Phi, \Delta} |
152 {\TApp{C}{\tau_0, \ldots, \tau_n}} | 271 {\TApp{C}{\tau_0, \ldots, \tau_n}} |
153 {\TApp{G}{\sigma_0, \ldots, \sigma_m}}} | 272 {\TApp{G}{\sigma_0, \ldots, \sigma_m}}} |
154 \end{array} | 273 |
155 \] | 274 \section*{Field and Method lookup} |
| 275 |
| 276 \subsection*{Field lookup} |
| 277 |
| 278 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u
psilon_k}}{\many{\mathit{ce}}}) \in \Phi \\ |
| 279 \fieldDecl{x}{\tau} \in \many{\mathit{ce}} |
| 280 } |
| 281 {\fieldLookup{\Phi}{\TApp{C}{\tau_0, \ldots, \tau_n}}{x}{\subst{\tau_0,
\ldots, \tau_n}{T_0, \ldots, T_n}{\tau}} |
| 282 } |
| 283 |
| 284 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u
psilon_k}}{\many{\mathit{ce}}}) \in \Phi \quad x \notin \many{\mathit{ce}} \\ |
| 285 \fieldLookup{\Phi}{\TApp{C'}{\upsilon_0, \ldots, \upsilon_k}}{x}{\tau} |
| 286 } |
| 287 {\fieldLookup{\Phi}{\TApp{C}{\tau_0, \ldots, \tau_n}}{x}{\subst{\tau_0,
\ldots, \tau_n}{T_0, \ldots, T_n}{\tau}} |
| 288 } |
| 289 |
| 290 \subsection*{Method lookup} |
| 291 |
| 292 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u
psilon_k}}{\many{\mathit{ce}}}) \in \Phi \\ |
| 293 \methodDecl{m}{\tau} \in \many{\mathit{ce}} |
| 294 } |
| 295 {\methodLookup{\Phi}{\TApp{C}{\tau_0, \ldots, \tau_n}}{m}{\subst{\tau_0,
\ldots, \tau_n}{T_0, \ldots, T_n}{\tau}} |
| 296 } |
| 297 |
| 298 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u
psilon_k}}{\many{\mathit{ce}}}) \in \Phi \quad m \notin \many{\mathit{ce}} \\ |
| 299 \methodLookup{\Phi}{\TApp{C'}{\upsilon_0, \ldots, \upsilon_k}}{m}{\tau} |
| 300 } |
| 301 {\methodLookup{\Phi}{\TApp{C}{\tau_0, \ldots, \tau_n}}{m}{\subst{\tau_0,
\ldots, \tau_n}{T_0, \ldots, T_n}{\tau}} |
| 302 } |
| 303 |
| 304 |
| 305 |
| 306 \section*{Typing} |
| 307 \input{static-semantics} |
| 308 |
| 309 \section*{Elaboration} |
| 310 |
| 311 These are the same rules, extended with a translated term which corresponds to |
| 312 the original term with the additional dynamic type checks inserted to reify the |
| 313 static unsoundness as runtime type errors. |
| 314 |
| 315 \setboolean{show_translation}{true} |
| 316 \input{static-semantics} |
| 317 |
156 | 318 |
157 \end{document} | 319 \end{document} |
OLD | NEW |