--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ var x: Int = 0
+ fun y(i: Int): Int do return x * i
+ fun y=(i, o: Int) do x = (o / i)
+end
+
+var a = new A
+a.x += 2
+a.x.output
+
+a.y(10).output
+a.y(10) += 30
+a.y(10).output
+
+a.x.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+interface Object
+end
+
+enum Char
+ fun output is intern
+end
+
+class A
+ init
+ do
+ 'A'.output
+ end
+end
+
+class B
+ super A
+ init
+ do
+ 'B'.output
+ end
+end
+
+class C
+ super A
+end
+
+var a = new A
+'\n'.output
+
+var b = new B
+'\n'.output
+
+var c = new C
+'\n'.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A[T]
+ type U: Object
+ fun testT(o: Object): Bool do return o isa T
+ fun testU(o: Object): Bool do return o isa U
+
+ fun get_c: C[U,T] do return new C[U,T]
+
+ fun testall
+ do
+ self.testT(1).output
+ self.testT(true).output
+ self.testU(1).output
+ self.testU(true).output
+ var c = get_c
+ c.testT(1).output
+ c.testT(true).output
+ c.testU(1).output
+ c.testU(true).output
+ '\n'.output
+ end
+end
+
+class B
+ super A[Int]
+ redef type U: Bool
+ fun foo: A[Bool] do return get_c
+end
+
+class C[V, W]
+ super A[V]
+ redef type U: W
+ fun foo: A[W] do return get_c
+end
+
+var ao = new A[Object]
+var ai = new A[Int]
+var b = new B
+var coo = new C[Object, Object]
+var cib = new C[Int, Bool]
+
+ao.testall
+ai.testall
+b.testall
+b.foo.testall
+coo.testall
+cib.testall
+cib.foo.testall
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+fun foo(i: Int)
+do
+ i.output
+ if i>0 then foo(i-1)
+ i.output
+end
+foo(5)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2006-2008 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+interface Object
+end
+
+enum Bool
+end
+
+enum Int
+ fun output is intern
+end
+
+class A
+ init do 5.output
+ fun run do 6.output
+end
+
+class B
+ var val: Int
+ init(v: Int)
+ do
+ 7.output
+ self.val = v
+ end
+ fun run do val.output
+end
+
+class C
+ var val1: Int
+ var val2: Int = 10
+end
+
+fun foo do 2.output
+fun bar(i: Int) do i.output
+fun baz: Int do return 4
+
+1.output
+foo
+bar(3)
+baz.output
+
+var a = new A
+a.run
+
+var b = new B(8)
+b.run
+
+var c = new C(9)
+c.val1.output
+c.val2.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+class Object
+end
+
+class A[E: Object]
+ fun e: E is abstract
+end
+
+class C[G: Object]
+ type V: A[G]
+ fun v: V is abstract
+ fun test
+ do
+ __debug__ type V : v
+ __debug__ type G : v.e
+ end
+end
+
+class B[F: A[X]]
+ fun f: F is abstract
+ fun test
+ do
+ __debug__ type F : f
+ __debug__ type X : f.e
+ end
+end
+
+class X
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+class Object
+ fun ==(o: nullable Object): Bool do return self is o
+ fun !=(o: nullable Object): Bool do return not self is o
+end
+
+class A
+end
+
+class Bool
+ fun output is intern
+end
+
+fun test(a: nullable A)
+do
+ #__debug__ type nullable A : a
+
+ #if a != null then
+ # __debug__ type A : a
+ #end
+
+ #__debug__ type nullable A : a
+
+ if a == null then
+ false.output
+ return
+ end
+
+ __debug__ type A : a
+
+ true.output
+end
+
+test(new A)
+test(null)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+class Object
+ fun ==(o: nullable Object): Bool do return self is o
+ fun !=(o: nullable Object): Bool do return not self is o
+end
+
+class A
+end
+
+class Bool
+ fun output is intern
+end
+
+fun maybe: Bool do return true
+
+fun test1(a: nullable A)
+do
+ var res = a
+ while res == null do
+ if maybe then
+ false.output
+ return
+ end
+ end
+ __debug__ type A : res
+ true.output
+end
+
+fun test2(a: nullable A)
+do
+ var res = a
+ while res != null do
+ __debug__ type A : res
+ if maybe then
+ false.output
+ return
+ end
+ end
+ true.output
+end
+
+test1(new A)
+test1(null)
+test2(new A)
+test2(null)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+class Object
+ fun ==(o: nullable Object): Bool is intern
+ fun !=(o: nullable Object): Bool is intern
+end
+
+class A
+end
+
+class Bool
+ fun output is intern
+end
+
+fun test(a: nullable A)
+do
+ __debug__ type nullable A : a
+
+ if a isa A then
+ __debug__ type A : a
+ end
+
+ __debug__ type nullable A : a
+
+ if not a isa A then
+ false.output
+ return
+ end
+
+ __debug__ type A : a
+
+ true.output
+end
+
+test(new A)
+test(null)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Power
+ var number: Int
+ var exponent: Int
+
+ fun iterate !each(i: Int)
+ do
+ var res = 1
+ for i in [0..self.exponent[ do
+ res = res * self.number
+ each(res)
+ end
+ end
+end
+
+for i in new Power(2, 8) do
+ print i
+end
--- /dev/null
+2
+20
+50
+5
--- /dev/null
+5
+4
+3
+2
+1
+0
+0
+1
+2
+3
+4
+5
--- /dev/null
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
--- /dev/null
+true
+false
--- /dev/null
+true
+false
+false
+true
--- /dev/null
+base_var_type_evolution_nullable.nit:33,5--11: Warning: Prefer '!= null'.
+base_var_type_evolution_nullable.nit:39,9--15: Warning: Prefer '!= null'.
+true
+false
--- /dev/null
+2
+4
+8
+16
+32
+64
+128
+256