return r
end
end
+
+redef class ADebugTypeExpr
+ redef fun generate_icode(v)
+ do
+ # Do nothing.
+ return null
+ end
+end
end
end
+redef class ADebugTypeExpr
+ redef fun after_typing(v)
+ do
+ if not v.check_expr(n_expr) then return
+ if not n_type.is_typed then return
+ var etype = n_expr.stype
+ var ttype = n_type.stype
+ if etype != ttype then
+ v.warning(self, "Warning: Expression is a {etype}, expected {ttype}.")
+ end
+ end
+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
+end
+
+class Int
+end
+
+class A[E: Object]
+ fun e: E is abstract
+
+ type V: E
+ fun v: V is abstract
+end
+
+class C[G: Int]
+ type U: A[G]
+
+ fun test(u: U)
+ do
+ __debug__ type G: u.e
+ __debug__ type G: u.v
+ end
+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
+end
+
+class Int
+end
+
+class Bool
+end
+
+class Char
+end
+
+class A[E, F]
+ type U: F
+
+ fun e: E is abstract
+ fun f: F is abstract
+ fun u: U is abstract
+
+ fun test1(a: A[E, F], ax: A[E, A[U, Int]])
+ do
+ __debug__ type E: self.e # E -> Object
+ __debug__ type F: self.f # F -> Object
+ __debug__ type U: self.u # U -> Object
+
+ __debug__ type E: a.e # E -> Object
+ __debug__ type F: a.f # F -> Object
+ __debug__ type F: a.u # F -> Object
+
+ __debug__ type A[U, Int]: ax.u # A[U, Int] -> A[Object, Int]
+ end
+end
+
+class B[G]
+ super A[Int, G]
+ fun g: G is abstract
+end
+
+class C[H: Char]
+ super B[Bool]
+
+ type W: B[H]
+
+ fun test3(b1: B[H], b2: B[W], w: W)
+ do
+ __debug__ type Int: self.e
+ __debug__ type U: self.u
+
+ __debug__ type H: b1.u
+
+ __debug__ type W: b2.u
+
+ __debug__ type H: w.u
+ end
+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 A
+end
+
+class G[T: A]
+ type U: A
+
+ var at: T
+ var au: U
+
+ fun test(t: T, u: U)
+ do
+ __debug__ type T: t
+ __debug__ type U: u
+
+ __debug__ type T: at
+ __debug__ type U: au
+ end
+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 A
+ var a: A = self
+ var na: nullable A = self
+end
+
+var a = new A
+__debug__ type A: a
+__debug__ type A: a.a
+__debug__ type nullable A: a.na
+__debug__ type nullable A: a.a.na
+__debug__ type A: a.na.a
--- /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 A
+ type T: A
+ var t: T = self
+ var nt: nullable T = self
+
+ type U: nullable A
+ var u: U = self
+ var nu: nullable U = self
+ fun test
+ do
+ __debug__ type T : self.t
+ __debug__ type nullable T : self.nt
+ __debug__ type U : self.u
+ __debug__ type nullable U : self.nu
+ end
+end
+
+var a = new A
+__debug__ type A : a.t
+__debug__ type nullable A : a.nt
+__debug__ type nullable A : a.u
+__debug__ type nullable A : a.nu
--- /dev/null
+base_types_formal_and_virtual2.nit:67,3--18: Warning: Expression is a B[H], expected W.