18.11.2012 Views

Well-typings for Java – The algorithm –

Well-typings for Java – The algorithm –

Well-typings for Java – The algorithm –

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

– It holds C ≤∗ C if <strong>for</strong> each θi and θ ′ i , respectively,<br />

one of the following conditions is valid3 • θi = ?θi, θ ′ i = ?θ ′<br />

i and θi ≤∗ θ ′<br />

i.<br />

• θi = ? θi, θ ′ i = ? θ ′<br />

i and θ ′<br />

i ≤∗ θi.<br />

• θi, θ ′ i ∈ STypeTS ( BT V ) and θi = θ ′ i<br />

• θ ′ i = ?θi<br />

• θ ′ i = ? θi<br />

(cp. [GJSB05] §4.5.1.1 type argument containment)<br />

– Let C be the capture conversions of C and<br />

C ≤∗ C then holds<br />

– θ ≤ ∗ θ|T<br />

C ≤ ∗ C.<br />

Definition 4 (Subtyping relation ≤ ∗ on TypeTS ( BT V )). Let ≤ ∗ be a<br />

subtyping relation on simple types STypeTS ( BT V ). <strong>The</strong>n, the extension to<br />

TypeTS ( BT V ) is defined as:<br />

# θ (θ ′ 1, . . . , θ ′ n) ≤ ∗ # θ ′ (θ1, . . . , θn) iff θ ≤ ∗ θ ′ and θi ≤ ∗ θ ′ i.<br />

Example 1. Let the following <strong>Java</strong>λ program be given.<br />

class Matrix extends Vector {<br />

}<br />

##Matrix(#Matrix(Matrix, Matrix))(Matrix)<br />

op = #{ Matrix m -> #{ #Matrix(Matrix, Matrix) f -> f(Matrix.this, m)}}<br />

#Matrix(Matrix, Matrix)<br />

mul = #{ (Matrix m1, Matrix m2) -><br />

Matrix ret = new Matrix ();<br />

<strong>for</strong>(int i = 0; i < size(); i++) {<br />

Vector

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!