1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
discard """
output: '''
foo1
foo2
'''
"""
block:
type
FooObj[T] = object
v: T
Foo1[T] = FooObj[T]
Foo2 = FooObj
proc foo1(x: Foo1) = echo "foo1"
proc foo2(x: Foo2) = echo "foo2"
var x: FooObj[float]
foo1(x) # works
foo2(x) # works
block:
type
FooObj[T] = T
Foo1[T] = FooObj[T]
Foo2 = FooObj
Foo3 = Foo1
Foo4x = FooObj[SomeInteger]
Foo4 = FooObj[SomeFloat]
Foo5x = Foo1[SomeInteger]
Foo5 = Foo1[SomeFloat]
proc foo0(x: FooObj): int = 0
proc foo1(x: Foo1): int = 1
proc foo2(x: Foo2): int = 2
proc foo3(x: Foo3): int = 3
proc foo4(x: Foo4x): int = 40
proc foo4(x: Foo4): int = 4
proc foo5(x: Foo5x): int = 50
proc foo5(x: Foo5): int = 5
block:
var x: FooObj[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
var x: Foo1[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
var x: Foo2[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
type
FooObj[T,U] = object
x: T
y: U
Foo1[U,T] = FooObj[T,U]
Foo2 = FooObj
Foo3 = Foo1
Foo4x = FooObj[SomeInteger,SomeInteger]
Foo4y = FooObj[SomeInteger,SomeFloat]
Foo4z = FooObj[SomeFloat,SomeFloat]
Foo4 = FooObj[SomeFloat,SomeInteger]
Foo5x = Foo1[SomeInteger,SomeInteger]
Foo5y = Foo1[SomeFloat,SomeInteger]
Foo5z = Foo1[SomeFloat,SomeFloat]
Foo5 = Foo1[SomeInteger,SomeFloat]
proc foo0(x: FooObj): int = 0
proc foo1(x: Foo1): int = 1
proc foo2(x: Foo2): int = 2
proc foo3(x: Foo3): int = 3
proc foo4(x: Foo4x): int = 40
proc foo4(x: Foo4y): int = 41
proc foo4(x: Foo4z): int = 42
proc foo4(x: Foo4): int = 4
proc foo5(x: Foo5x): int = 50
proc foo5(x: Foo5y): int = 51
proc foo5(x: Foo5z): int = 52
proc foo5(x: Foo5): int = 5
block:
var x: FooObj[float,int]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
var x: Foo1[int,float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
type
FooObj[T] = object of RootObj
v: T
FooObj2[T] = object of FooObj[T]
Foo1[T] = FooObj[T]
Foo2 = FooObj
Foo3 = Foo1
Foo4x = FooObj[SomeInteger]
Foo4 = FooObj[SomeFloat]
Foo5x = Foo1[SomeInteger]
Foo5 = Foo1[SomeFloat]
proc foo0(x: FooObj): int = 0
proc foo1(x: Foo1): int = 1
proc foo2(x: Foo2): int = 2
proc foo3(x: Foo3): int = 3
proc foo4(x: Foo4x): int = 40
proc foo4(x: Foo4): int = 4
proc foo5(x: Foo5x): int = 50
proc foo5(x: Foo5): int = 5
block:
var x: FooObj[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
block:
var x: Foo1[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
#[ XXX These still fail
block:
var x: FooObj2[float]
doAssert(foo0(x) == 0)
doAssert(foo1(x) == 1)
doAssert(foo2(x) == 2)
doAssert(foo3(x) == 3)
doAssert(foo4(x) == 4)
doAssert(foo5(x) == 5)
]#
|