1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
25 redef fun toto
(x
) do return x
+ self
27 fun mult_by
(x
: Int): Int do return x
* self
56 return "x is {x.as(not null)}"
61 fun bar
: C
[E
] do return self
62 fun foo
: Fun0[C
[E
]] do return &bar
69 print f1
.call
# "in A::fun1"
72 print f2
.call
# "in B::fun1"
75 print f3
.call
(10) # 100
78 print f4
.call
# "in B::fun1"
80 var f5
: Fun0[Object] = &f4
.call
84 print
((&10.toto
).call
(100)) # 110
85 print
((&"allo".toto
).call
(2)) # 3
89 var ps
= [p1
,p1
,p1
,p1
,p1
]
94 var c1
= new C
[nullable Object](null)
95 var c2
= new C
[nullable Int](null)
100 print f6
.call
# "x is null"
101 print f7
.call
# "x is null"
106 print f6
.call
# "x is test"
107 print f7
.call
# "x is 100"
110 print f8
.call
# "x is 100"