Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into let
Browse files Browse the repository at this point in the history
Conflicts:
	Ceylon.g
  • Loading branch information
FroMage committed Nov 14, 2014
2 parents 58fa480 + 844cec3 commit 95b60e0
Show file tree
Hide file tree
Showing 40 changed files with 1,598 additions and 444 deletions.
286 changes: 213 additions & 73 deletions typechecker/Ceylon.g

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions typechecker/Ceylon.nodes
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@
^(DEFAULTED_TYPE:TYPE
TYPE)

^(SPREAD_TYPE:TYPE
TYPE)

"A control directive."
^(abstract DIRECTIVE:EXECUTABLE_STATEMENT)
^(RETURN:DIRECTIVE EXPRESSION?
Expand Down Expand Up @@ -420,9 +423,11 @@
ELSE_CLAUSE?)
^(IF_CLAUSE:CONTROL_CLAUSE
CONDITION_LIST
BLOCK?)
BLOCK?
EXPRESSION?)
^(ELSE_CLAUSE:CONTROL_CLAUSE
BLOCK?)
BLOCK?
EXPRESSION?)

^(SWITCH_STATEMENT:CONTROL_STATEMENT
SWITCH_CLAUSE
Expand All @@ -434,7 +439,8 @@
ELSE_CLAUSE?)
^(CASE_CLAUSE:CONTROL_CLAUSE
CASE_ITEM
BLOCK?)
BLOCK?
EXPRESSION?)

^(CASE_ITEM)
^(MATCH_CASE:CASE_ITEM
Expand Down Expand Up @@ -649,7 +655,9 @@

^(abstract STATIC_MEMBER_OR_TYPE_EXPRESSION:MEMBER_OR_TYPE_EXPRESSION
IDENTIFIER
TYPE_ARGUMENTS?)
TYPE_ARGUMENTS?
ProducedTypedReference targetParameter;
ProducedType parameterType;)

^(abstract BASE_MEMBER_OR_TYPE_EXPRESSION:STATIC_MEMBER_OR_TYPE_EXPRESSION)

Expand Down Expand Up @@ -733,6 +741,23 @@
BLOCK?
Method declarationModel;)

"An anonymous function."
^(OBJECT_EXPRESSION:TERM
EXTENDED_TYPE?
SATISFIED_TYPES?
CLASS_BODY
Class anonymousClass;)

"An if/then/else conditional expression."
^(IF_EXPRESSION:TERM
IF_CLAUSE
ELSE_CLAUSE)

"A switch/case/else conditional expression."
^(SWITCH_EXPRESSION:TERM
SWITCH_CLAUSE
SWITCH_CASE_LIST)

"A named argument."
^(abstract NAMED_ARGUMENT:STATEMENT_OR_ARGUMENT
IDENTIFIER?
Expand Down
4 changes: 2 additions & 2 deletions typechecker/en/modules/declarations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,15 +1134,15 @@ TypeConstraints?
<programlisting>class Graph() {
OpenList&lt;Node&gt; nodes = ArrayList&lt;Node&gt;();
class Node() {
nodes.add(this); //compiler error (this reference in initializer)
nodes.add(this); //error: self reference in initializer
}
}</programlisting>

<programlisting>class Graph() {
class Node() {}
Node createNode() {
Node node = Node();
nodes.add(node); //compiler error (forward reference in initializer)
nodes.add(node); //error: forward reference in initializer
return node;
}
OpenList&lt;Node&gt; nodes = ArrayList&lt;Node&gt;();
Expand Down
66 changes: 61 additions & 5 deletions typechecker/en/modules/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,24 @@ Digit{1,2} ":" Digit{2} ( ":" Digit{2} ( ":" Digit{3} )? )?
the realization of the referenced function or class.</para>

<para>If a callable reference expression refers to a generic declaration,
either:</para>
it must either:</para>

<itemizedlist>
<listitem>
<para>it must be immediately followed by an argument list,
allowing the compiler to infer the type arguments, or</para>
<para>have an explicit type argument list,</para>
</listitem>
<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>it must have an explicit type argument list.</para>
<para>occur as a listed argument, as defined in
<xref linkend="listedarguments"/> in a positional argument
list, or as a specified argument, anonymous argument, or
listed argument, as defined in <xref linkend="namedarguments"/>,
in a named argument list, and its type arguments must be
inferable as defined below.</para>
</listitem>
</itemizedlist>

Expand All @@ -621,6 +630,27 @@ Digit{1,2} ":" Digit{2} ( ":" Digit{2} ( ":" Digit{3} )? )?
reference. This would also allow static references like
<literal>Person.@name</literal>.</para></comment>

<para>If a callable reference <literal>f</literal> with no explicit type
argument list occurs as the argument to a callable parameter <literal>p</literal>
of a function or class in a direct invocation expression, as defined below in
<xref linkend="directinvocations"/>, then the type arguments of <literal>f</literal>
are inferred according to the rules defined in <xref linkend="typeargumentinference"/>
as if the types of the parameters of <literal>p</literal> were the types of
listed arguments of <literal>f</literal> in a positional argument list, unless
the invoked function or class is generic, and the invocation expression does
not itself specify explicit type arguments, in which case any parameter whose
type involves a type argument of the invoked function or class is ignored.</para>

<para>If a callable reference <literal>f</literal> with no explicit type
argument list occurs as the argument to a value parameter <literal>p</literal>
of type <literal>Callable&lt;Return,Args&gt;</literal> in a direct or indirect
invocation expression, then the type arguments of <literal>f</literal> are
inferred according to the rules defined in <xref linkend="typeargumentinference"/>
as if <literal>Args</literal> were the type of a positional argument list, unless
the invocation is a direct invocation expression, and the invoked function or
class is generic, and <literal>Args</literal> involves type parameters of the
invoked function or class.</para>

</section>

<section id="staticexpressions">
Expand Down Expand Up @@ -652,6 +682,32 @@ Digit{1,2} ":" Digit{2} ( ":" Digit{2} ( ":" Digit{3} )? )?
<para>A static expression must reference a statically typed declaration with no missing
types, even within a <literal>dynamic</literal> block.</para>

<para>If the qualifying type in a static expression refers to a generic declaration, then
either:</para>

<itemizedlist>
<listitem>
<para>it must have an explicit type argument list, or</para>
</listitem>
<listitem>
<para>the static expression must occur as a listed argument, as defined in
<xref linkend="listedarguments"/> in a positional argument list, or as a
specified argument, anonymous argument, or listed argument, as defined in
<xref linkend="namedarguments"/>, in a named argument list, and its type
arguments must be inferable as defined below.</para>
</listitem>
</itemizedlist>

<para>If a static expression <literal>T.m</literal> for a generic type <literal>T</literal>
with no explicit type argument list occurs as the argument to a parameter <literal>p</literal>
of type <literal>Callable&lt;Return,Arg&gt;</literal> in a direct or indirect invocation
expression, then the type arguments of <literal>T</literal> are inferred according to the
rules defined in <xref linkend="typeargumentinference"/> as if <literal>Arg</literal>
were the type of a positional argument list, and <literal>[T]</literal> were the type of
a parameter list, unless the invocation is a direct invocation expression, and the invoked
function or class is generic, and <literal>Arg</literal> involves type parameters of the
invoked function or class.</para>

</section>

<section id="staticvaluereferences">
Expand Down Expand Up @@ -2274,7 +2330,7 @@ Digit{1,2} ":" Digit{2} ( ":" Digit{2} ( ":" Digit{3} )? )?
<row>
<entry><literal>lhs[index]</literal></entry>
<entry>lookup</entry>
<entry><literal>lhs.item(index)</literal></entry>
<entry><literal>lhs.get(index)</literal></entry>
<entry><literal>Correspondence&lt;X,Y&gt;</literal></entry>
<entry><literal>X</literal></entry>
<entry><literal>Y?</literal></entry>
Expand Down
23 changes: 13 additions & 10 deletions typechecker/en/modules/statementblocks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ Integer f(Integer n) => n+package.n;</programlisting>
<para>This code is not legal, since the body of a function is an ordinary block:</para>

<programlisting>Float->Float xy() {
Float x => y; //compiler error: y is not referenceable
Float x => y; //error: y is not referenceable
Float y => x;
return x->y;
}</programlisting>
Expand All @@ -611,7 +611,7 @@ Integer f(Integer n) => n+package.n;</programlisting>
section of the class body:</para>

<programlisting>class Point() {
Float x => y; //compiler error: y is not referenceable
Float x => y; //error: y is not referenceable
Float y => x;
Float->Float xy = x->y;
}</programlisting>
Expand Down Expand Up @@ -663,7 +663,7 @@ Integer f(Integer n) => n+package.n;</programlisting>
<para>The following code is not legal:</para>

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

Expand Down Expand Up @@ -1057,11 +1057,12 @@ Integer f(Integer n) => n+package.n;</programlisting>
<para>The persistent value of a forward-declared reference or the implementation
of a forward-declared function may be specified by a <emphasis>value specification
statement</emphasis>. The value specification statement consists of an unqualified
value reference and an ordinary <literal>=</literal> specifier. The value reference
must refer to a declaration which sequentially occurs earlier in the body in which
the specification statement occurs.</para>
value reference, or a qualified value reference where the receiver expression is
`this`, and an ordinary <literal>=</literal> specifier. The value reference must
refer to a declaration which sequentially occurs earlier in the body in which the
specification statement occurs.</para>

<synopsis>ValueSpecification: MemberName Specifier ";"</synopsis>
<synopsis>ValueSpecification: ("this" ".")? MemberName Specifier ";"</synopsis>

<para>The type of the specified expression must be assignable to the type of the
reference, or to the callable type of the function.</para>
Expand Down Expand Up @@ -1100,11 +1101,13 @@ else {

<itemizedlist>
<listitem>
<para>an unqualified value reference and a lazy
<para>an unqualified value reference, or a qualified value reference
where the receiver expression is `this`, and a lazy
<literal>=&gt;</literal> specifier, or</para>
</listitem>
<listitem>
<para>a unqualified callable reference, one or more parameter lists,
<para>a unqualified callable reference, or a qualified value reference
where the receiver expression is `this`, one or more parameter lists,
and a lazy specifier.</para>
</listitem>
</itemizedlist>
Expand All @@ -1120,7 +1123,7 @@ else {
<literal>R</literal>. Then the type of the parameterized reference is
<literal>R</literal>.</para>

<synopsis>ParameterizedReference: MemberName Parameters+</synopsis>
<synopsis>ParameterizedReference: ("this" ".")? MemberName Parameters+</synopsis>

<para>Thus, the specification statement consists of a parameterized reference
followed by a lazy specifier.</para>
Expand Down
Loading

0 comments on commit 95b60e0

Please sign in to comment.