blob: d5d26dac9f51d3efcabe28687afe066b5a3bf4ad [file] [log] [blame]
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../css/ot.css" />
<link rel="stylesheet" type="text/css" href="../css/otjld.css" />
<title>OT/J Language Definition v1.3.1</title>
</head>
<body class="otdt">
<div id="content">
<table class="nav">
<tr>
<td class="back"><a id="top"></a><a href="s1.3.1.d.html" rel="prev">&lt;&lt;&nbsp;&sect;1.3.1.(d)&nbsp;Lack of subtyping</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"><a href="s1.3.1.f.html" rel="next">&sect;1.3.1.(f)&nbsp;tsuper&nbsp;&gt;&gt;</a></td>
</tr>
</table>
<div class="breadcrumb"><a class="nav" href="s1.html" rel="section">&sect;1&nbsp;Teams and Roles</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.html" rel="section">&sect;1.3&nbsp;Acquisition and implicit inheritance of role classes</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.1.html" rel="section">&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></div>
<div class="subsect depth4" id="s1.3.1.e">
<h4 class="subsect">&sect;1.3.1.(e)&nbsp;<span class="title">Dynamic binding of types</span><a class="img" href="s1.3.1.e.html"
title="PermaLink to (e)&nbsp;Dynamic binding of types"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>Overriding an acquired role by a new role class has the following
implication: If an expression or declaration, which is evaluated on behalf of
an instance of team <code>T</code> or one of its contained roles,
refers to a role <code>R</code>, <code>R</code> will always
resolve to <code>T.R</code> even if <code>R</code> was introduced in
a super-team of <code>T</code> and even if the specific line of code
was inherited from a super-team or one of its roles.
Only the dynamic type of the enclosing team-instance is used to determine
the correct role class (see below for an example).
</p>
<p>A special case of dynamically binding role types relates to so-called class literals
(see <a href="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#251530"
class="ext">JLS &sect;15.8.2</a>).
Role class literals are covered in <a href="s6.1.c.html" title="&sect;6.1.(c)&nbsp;Class literals for roles"
class="sect">&sect;6.1.(c)</a>.
</p>
<p>The above is strictly needed only for cases involving implicit inheritance.
It may, however, help intuition, to also consider the directly acquired
role <code>T.R</code> in (b) to override the given role <code>S.R</code>.
</p>
<div class="codecomment">
In line 17 of <a href="s1.html#l1.3.1-1" class="listing">Listing 1.3.1-1</a> the implicitly inherited method <code>n</code> is called
with the result of an invocation of <code>m</code>. Although
<code>n</code> was defined in <code>S</code> (thus with argument type
<code>S.R2, see line 6</code>) in the context of <code>T</code> it
expects an argument of <code>T.R2</code>. This is correctly provided by
the invocation of <code>m</code> in the context of <code>T</code>.
</div>
</div>
<table class="nav">
<tr>
<td class="back"><a href="s1.3.1.d.html" rel="prev">&lt;&lt;&nbsp;&sect;1.3.1.(d)&nbsp;Lack of subtyping</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"><a href="s1.3.1.f.html" rel="next">&sect;1.3.1.(f)&nbsp;tsuper&nbsp;&gt;&gt;</a></td>
</tr>
</table>
<div class="breadcrumb"><a class="nav" href="s1.html" rel="section">&sect;1&nbsp;Teams and Roles</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.html" rel="section">&sect;1.3&nbsp;Acquisition and implicit inheritance of role classes</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.1.html" rel="section">&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></div>
</div>
<div id="footer">
<hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer"
shape="rect"><img src="../images/valid-css2-blue.png" alt="Valid CSS!" height="31" width="88" /></a><a class="w3c img" href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="../images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31"
width="88" /></a><address>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
OT/J version 1.3.1 &mdash; last modified: 2013-05-28
</div>
</body>
</html>