summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorjcosborn <jcosborn@users.noreply.github.com>2020-08-27 05:56:38 -0500
committerGitHub <noreply@github.com>2020-08-27 12:56:38 +0200
commitd11933ad998fb0a3eb51bbefbaa53e583aaa3ac1 (patch)
tree3c6a4f43932120fd5abc8fc5a720efe7e7657b64 /tests
parentccccd30cf6b8704c224e42001d0def2b566d5388 (diff)
downloadNim-d11933ad998fb0a3eb51bbefbaa53e583aaa3ac1.tar.gz
fix some issues overloading with generics and inheritance (#15211)
* fix some issues overloading with generics and inheritance

* fix passing procs with subtype matches
Diffstat (limited to 'tests')
-rw-r--r--tests/overload/toverload_various.nim36
1 files changed, 31 insertions, 5 deletions
diff --git a/tests/overload/toverload_various.nim b/tests/overload/toverload_various.nim
index e8a0108e3..132c3be4b 100644
--- a/tests/overload/toverload_various.nim
+++ b/tests/overload/toverload_various.nim
@@ -411,7 +411,7 @@ block:
   test(d, 2)
 
 
-# inheritance depth
+# inheritance and generics
 block:
   type
     Foo[T] = object of RootObj
@@ -421,17 +421,43 @@ block:
     Baz[T] = object of Bar[T]
       z: T
 
-  template t0[T](x: Foo[T]): int = 0
-  template t0[T](x: Bar[T]): int = 1
-  proc p0[T](x: Foo[T]): int = 0
-  proc p0[T](x: Bar[T]): int = 1
+  template t0(x: Foo[int]): int = 0
+  template t0(x: Bar[int]): int = 1
+  template t0(x: Foo[bool or int]): int = 10
+  template t0(x: Bar[bool or int]): int = 11
+  template t0[T](x: Foo[T]): int = 20
+  template t0[T](x: Bar[T]): int = 21
+  proc p0(x: Foo[int]): int = 0
+  proc p0(x: Bar[int]): int = 1
+  #proc p0(x: Foo[bool or int]): int = 10
+  #proc p0(x: Bar[bool or int]): int = 11
+  proc p0[T](x: Foo[T]): int = 20
+  proc p0[T](x: Bar[T]): int = 21
 
   var a: Foo[int]
   var b: Bar[int]
   var c: Baz[int]
+  var d: Foo[bool]
+  var e: Bar[bool]
+  var f: Baz[bool]
+  var g: Foo[float]
+  var h: Bar[float]
+  var i: Baz[float]
   doAssert(t0(a) == 0)
   doAssert(t0(b) == 1)
   doAssert(t0(c) == 1)
+  doAssert(t0(d) == 10)
+  doAssert(t0(e) == 11)
+  doAssert(t0(f) == 11)
+  doAssert(t0(g) == 20)
+  doAssert(t0(h) == 21)
+  #doAssert(t0(i) == 21)
   doAssert(p0(a) == 0)
   doAssert(p0(b) == 1)
   doAssert(p0(c) == 1)
+  #doAssert(p0(d) == 10)
+  #doAssert(p0(e) == 11)
+  #doAssert(p0(f) == 11)
+  doAssert(p0(g) == 20)
+  doAssert(p0(h) == 21)
+  doAssert(p0(i) == 21)