Java does not permit local interfaces or interfaces declared within inner types.
If we can't fix 'javac' to compile all local and inner interfaces then we'll do the following:
All Ceylon interfaces (top level, inner and local) will be generated at the top level in Java. The Java interface name will be constructed from the names of the types and/or methods containing the Ceylon interface definition. Local types will include a count for disambiguation.
When an interface has concrete members or defaulted parameters a Java companion class will be generated at the point where the Ceylon interface is defined. The companion class will therefore be able to capture everything necessary for the concrete interface members and interface method parameters defaults.
A method m
with default parameters on a top level class C
shall use a member method for each defaulted parameter.
This gives access to private members of C
.
Any type parameters of C
are in scope.
It's top level so there's no need to worry about closure.
A method m
with default parameters on a top level interface I
shall use a sibling companion class I$impl
.
I$impl
will be declared with the same type parameters as I
.
There can no private members of I
to worry about (because I
is an interface).
It's top level there's no need to worry about closure.
The initializer on a top level class C
shall use a sibling companion class C$impl
.
C$impl
will be declared with the same type parameters as C
.
It's impossible to access private members of C
(because we're creating an instance).
It's top level there's no need to worry about closure.
The methods on C$impl
will be static and declared with the same type parameters as C
.
A method m
with default parameters on an inner class IC
of outer
class OC
shall use a member method for each defaulted parameter.
This gives access to private members of IC
and OC
.
Any type parameters of IC
and OC
are in scope.
The default methods have the same closure as m
.
A method m
with default parameters on an inner class IC
of outer
interface OI
shall use a member method for each defaulted parameter.
This gives access to private members of IC
.
There can no private members of OI
worry about (because OI
is an interface).
Any type parameters of IC
and OI
are in scope.
The default methods have the same closure as m
.
A method m
with default parameters on an inner interface II
of outer class
OC
shall use a companion class II$impl
.
II$impl
will be declared with the same type parameters as II
.
There can no private members of II
to worry about (because its an interface)
II$impl
will be defined at an equivalent point in the Java as
II
is defined in the Ceylon.
II$impl
will therefore have the same closure as II
does in Ceylon and
have access to the same type parameters.
A method m
with default parameters on an inner interface II
of outer interface
OI
shall use a companion class II$impl
.
II$impl
will be declared with the same type parameters as II
.
There can no private members of II
to worry about (because its an interface)
There can no private members of OI
to worry about (because its an interface)
II$impl
will be defined at an equivalent point in the Java as
II
is defined in the Ceylon.
II$impl
will therefore have the same closure as II
does in Ceylon and
have access to the same type parameters.
The initializer on an inner class IC
of outer class OC
shall use a sibling companion class IC$impl
.
IC$impl
will be declared with the same type parameters as IC
.
It's impossible to access private members of IC
(because we're creating an instance).
IC$impl
is declared immediately after IC
so it has the same closure as IC
in particular is has access to OC
's private members and type parameters.
The initializer on an inner class IC
of outer interface OI
shall use a sibling companion class IC$impl
.
IC$impl
will be declared with the same type parameters as IC
.
It's impossible to access private members of IC
(because we're creating an instance).
IC$impl
is declared immediately after IC
so it has the same closure as IC
in particular is has access to OI
's type parameters.
A method m
with default parameters on an local class LC
shall use a member method for each defaulted parameter.
This gives access to private members of LC
and its closure and means that any
type parameters of LC
and its closure are in scope.
A method m
with default parameters on an local interface LI
shall
use a companion class LI$impl
.
LI$impl
will be declared with the same type parameters as LI
.
There can no private members of LI
to worry about (because its an interface),
LI$impl
will be defined at an equivalent point in the Java as
LI
is defined in the Ceylon.
LI$impl
will therefore have the same closure as LI
does in Ceylon and
have access to the same type parameters.
The initializer on an local class LC
shall use a sibling companion class LC$impl
.
LC$impl
will be declared with the same type parameters as LC
.
It's impossible to access private members of LC
(because we're creating an instance).
LC$impl
is declared immediately after IC
so it has the same closure as LC