--- /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 G[E]
+ fun foo(e: E): E
+ do
+ var ee = e.as(not null)
+ ee.output
+ return ee
+ end
+end
+
+class A
+ super G[Object]
+ redef fun foo(e)
+ do
+ var ee = e.as(not null)
+ ee.output
+ return ee
+ end
+end
+
+class B[F: Object]
+ super G[nullable F]
+ redef fun foo(e)
+ do
+ var ee = e.as(not null)
+ ee.output
+ return ee
+ end
+end
+
+class C[F: Object]
+ super G[F]
+ redef fun foo(e)
+ do
+ var ee = e.as(not null)
+ ee.output
+ return ee
+ end
+end
+
+var a = new A
+a.foo(1).output
+#alt1#a.foo(null).output
+var b = new B[Int]
+b.foo(2).output
+#alt2#b.foo(null).output
+var c = new C[Int]
+c.foo(3).output
+#alt3#c.foo(null).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
+
+var i: Int = 1
+i.as(not null).output
+var oi: Object = i
+oi.as(not null).output
+var ni: nullable Int = i
+ni.as(not null).output
+
+base_as_notnull.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+base_as_notnull.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+base_as_notnull.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+base_as_notnull.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
1
2
3
--- /dev/null
+base_as_notnull2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+base_as_notnull2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+1
+1
+2
+2
+3
+3
--- /dev/null
+alt/base_as_notnull2_alt1.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt1.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt1.nit:58,7--10: Type error: expected Object, got null
--- /dev/null
+alt/base_as_notnull2_alt2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+Runtime error: Cast failed (alt/base_as_notnull2_alt2.nit:40)
+1
+1
+2
+2
--- /dev/null
+alt/base_as_notnull2_alt3.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt3.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt3.nit:64,7--10: Type error: expected Int, got null
+alt/base_as_notnull_alt1.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt1.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt1.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt1.nit:50,6--19: Warning: expression is already not null, since it is a `A`.
alt/base_as_notnull_alt1.nit:50,6--19: Type error: expected B, got A
+alt/base_as_notnull_alt1.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt2.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt2.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt2.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt2.nit:51,6--20: Warning: expression is already not null, since it is a `A`.
alt/base_as_notnull_alt2.nit:51,6--20: Type error: expected B, got A
+alt/base_as_notnull_alt2.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt3.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt3.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt3.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt3.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
alt/base_as_notnull_alt3.nit:53,6--20: Type error: expected B, got A
+alt/base_as_notnull_alt4.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt4.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt4.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt4.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
alt/base_as_notnull_alt4.nit:54,6--21: Type error: expected B, got A
+alt/base_as_notnull_alt5.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt5.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt5.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt5.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
Runtime error: Cast failed (alt/base_as_notnull_alt5.nit:59)
1
2
+alt/base_as_notnull_alt6.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt6.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt6.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt6.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
Runtime error: Cast failed (alt/base_as_notnull_alt6.nit:60)
1
2
+alt/base_as_notnull_alt7.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt7.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt7.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt7.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
alt/base_as_notnull_alt7.nit:61,1--17: Type error: as(not null) on null
--- /dev/null
+base_as_notnull_int.nit:18,1--14: Warning: expression is already not null, since it is a `Int`.
+base_as_notnull_int.nit:20,1--15: Warning: expression is already not null, since it is a `Object`.
+1
+1
+1
alt/error_expr_not_ok_alt4.nit:149,7--24: Type error: expected A, got String
alt/error_expr_not_ok_alt4.nit:150,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt4.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt4.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
alt/error_expr_not_ok_alt4.nit:151,7--23: Type error: expected A, got Int
alt/error_expr_not_ok_alt4.nit:152,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt4.nit:152,7--18: Type error: expected A, got Bool
alt/error_expr_not_ok_alt5.nit:149,7--24: Type error: expected A, got String
alt/error_expr_not_ok_alt5.nit:150,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt5.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt5.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
alt/error_expr_not_ok_alt5.nit:151,7--23: Type error: expected A, got Int
alt/error_expr_not_ok_alt5.nit:152,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt5.nit:152,7--18: Type error: expected A, got Bool
alt/error_expr_not_ok_alt6.nit:149,7--24: Type error: expected A, got String
alt/error_expr_not_ok_alt6.nit:150,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt6.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt6.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
alt/error_expr_not_ok_alt6.nit:151,7--23: Type error: expected A, got Int
alt/error_expr_not_ok_alt6.nit:152,7--18: Warning: Expression is already a Int.
alt/error_expr_not_ok_alt6.nit:152,7--18: Type error: expected A, got Bool