Skip to content

Commit

Permalink
spec for #1224
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Mar 10, 2015
1 parent 8faa124 commit 4fde717
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion en/modules/declarations.xml
Expand Up @@ -437,7 +437,7 @@ TypeConstraints?

<para>As a special exception, if a parameter of an anonymous function has no explicit
type declaration, and there is no declaration with the given name occurring in the body
of the anonymous function, then the type of the parameyer must be inferrable, according
of the anonymous function, then the type of the parameyer must be inferable, according
to <xref linkend="parametertypeinference"/>.</para>

<para>Conversely, every parameter declaration that occurs outside a parameter list must
Expand Down
6 changes: 6 additions & 0 deletions en/modules/expressions.xml
Expand Up @@ -656,6 +656,12 @@ Digit{1,2} ":" Digit{2} ( ":" Digit{2} ( ":" Digit{3} )? )?
<listitem>
<para>be immediately followed by an argument list, allowing the
compiler to infer the type arguments, as defined in
<xref linkend="typeargumentinference"/>, or,</para>
</listitem>
<listitem>
<para>be the immediate child of a constructor expression that is
immediately followed by an argument list, allowing the compiler to
infer the type arguments, as defined in
<xref linkend="typeargumentinference"/>, or</para>
</listitem>
<listitem>
Expand Down
14 changes: 7 additions & 7 deletions en/modules/statementblocks.xml
Expand Up @@ -648,30 +648,30 @@ Integer f(Integer n) => n+package.n;</programlisting>
<para>A value declared using the keyword <literal>value</literal> or a
function declared using the keyword <literal>function</literal> may be
in scope at a program element, but its type may not be
<emphasis>inferrable</emphasis>, as defined by
<emphasis>inferable</emphasis>, as defined by
<xref linkend="typeinference"/>, from the point of view of that program
element.</para>

<para>The type of a value or function declared using the keyword
<literal>value</literal> or <literal>function</literal> is inferrable
<literal>value</literal> or <literal>function</literal> is inferable
to a program element if the declaration is in scope at the program
element and the program element occurs within the lexical scope of the
declaration.</para>

<comment><para>Note: the type of a value or function declared using
the keyword <literal>value</literal> or <literal>function</literal> is
not inferrable within the body of the value or function
not inferable within the body of the value or function
itself.</para></comment>

<para>For any other declaration, including any declaration which
explicitly specifies its type, the type is considered inferrable to a
explicitly specifies its type, the type is considered inferable to a
program element if the declaration is in scope at the program
element.</para>

<para>The following code is not legal:</para>

<programlisting>interface Point {
value x => y; //error: type of y is not inferrable
value x => y; //error: type of y is not inferable
value y => x;
}</programlisting>

Expand Down Expand Up @@ -745,7 +745,7 @@ Integer f(Integer n) => n+package.n;</programlisting>
<para>the declaration must be referenceable at the program element,</para>
</listitem>
<listitem>
<para>the type of the declaration must be inferrable to the program
<para>the type of the declaration must be inferable to the program
element, and</para>
</listitem>
<listitem>
Expand Down Expand Up @@ -879,7 +879,7 @@ Integer f(Integer n) => n+package.n;</programlisting>
element,</para>
</listitem>
<listitem>
<para>the type of the member must be inferrable to the program
<para>the type of the member must be inferable to the program
element, and</para>
</listitem>
<listitem>
Expand Down
21 changes: 17 additions & 4 deletions en/modules/typesystem.xml
Expand Up @@ -2391,10 +2391,23 @@ interface NumberLiteral
<title>Type argument inference</title>

<para>When a direct invocation expression, as defined by
<xref linkend="invocationexpressions"/>, for a generic function or a direct
instantiation expression for a generic class does not explicitly specify type
arguments, the type arguments are inferred from the argument expression types.
The types of the argument expressions and the declared types of the corresponding
<xref linkend="invocationexpressions"/>, does not explicitly specify type
arguments, the type arguments are inferred from the argument expression types.</para>

<itemizedlist>
<listitem>
<para>In the case of a direct invocation of a function or class, type
arguments are inferred for the type parameters of the function or
class.</para>
</listitem>
<listitem>
<para>In the case of a direct invocation of a constructor, type
arguments are inferred for the type parameters of the class to which
the constructor belongs.</para>
</listitem>
</itemizedlist>

<para>The types of the argument expressions and the declared types of the corresponding
parameters determine an <emphasis>inferred lower bound</emphasis> or
<emphasis>inferred upper bound</emphasis> for each type parameter.</para>

Expand Down

0 comments on commit 4fde717

Please sign in to comment.