implement the special treatment of explicit type params in concepts

This commit is contained in:
Zahary Karadjov 2016-08-12 16:45:28 +03:00
commit 644d645ea7
6 changed files with 20 additions and 5 deletions

View file

@ -25,7 +25,7 @@ type
# more complicated static param inference cases
m.data is array[TotalElements, T]
M.foo(array[0..FromFoo, type m[int, 10]])
m.foo(array[0..FromFoo, type m[int, 10]])
MyMatrix[M, K: static[int]; T] = object
data: array[M*K, T]

View file

@ -15,6 +15,9 @@ type
TObj = object
x: int
JSonValue = object
val: string
Sortable = concept x, y
(x < y) is bool
@ -49,9 +52,14 @@ type
staticproc(static[T])
typeproc T
T.typeproc
typeproc o.type
o.type.typeproc
o.to(type string)
o.to(type JsonValue)
refproc(r, intref)
varproc(v)
p.ptrproc(string)
@ -59,9 +67,9 @@ type
typeproc(T)
const TypeName = T.name
type MappedType = type(T.y)
type MappedType = type(o.y)
intval T.y
intval y(o)
let z = intval(o.y)
static:
@ -80,6 +88,8 @@ proc refproc(x: ref TObj, y: ref int) = discard
proc ptrproc(x: ptr TObj, y: string) = discard
proc staticproc(x: static[TObj]) = discard
proc typeproc(t: type TObj) = discard
proc to(x: TObj, t: type string) = discard
proc to(x: TObj, t: type JSonValue) = discard
proc testFoo(x: TFoo) =
echo x.TypeName