Merge pull request #2708 from nanoant/patch/dont-convert-subtype-typedesc-params
Fix #2662: Don't convert subtype typedesc params
This commit is contained in:
commit
f293e2c152
2 changed files with 23 additions and 1 deletions
|
|
@ -1281,6 +1281,9 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType,
|
||||||
result = implicitConv(nkHiddenStdConv, f, arg, m, c)
|
result = implicitConv(nkHiddenStdConv, f, arg, m, c)
|
||||||
of isSubtype:
|
of isSubtype:
|
||||||
inc(m.subtypeMatches)
|
inc(m.subtypeMatches)
|
||||||
|
if f.kind == tyTypeDesc:
|
||||||
|
result = arg
|
||||||
|
else:
|
||||||
result = implicitConv(nkHiddenSubConv, f, arg, m, c)
|
result = implicitConv(nkHiddenSubConv, f, arg, m, c)
|
||||||
of isSubrange:
|
of isSubrange:
|
||||||
inc(m.subtypeMatches)
|
inc(m.subtypeMatches)
|
||||||
|
|
|
||||||
19
tests/metatype/ttypedesc3.nim
Normal file
19
tests/metatype/ttypedesc3.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import typetraits
|
||||||
|
|
||||||
|
type
|
||||||
|
Base = object of RootObj
|
||||||
|
Child = object of Base
|
||||||
|
|
||||||
|
proc pr(T: typedesc[Base]) = echo "proc " & T.name
|
||||||
|
method me(T: typedesc[Base]) = echo "method " & T.name
|
||||||
|
iterator it(T: typedesc[Base]) = yield "yield " & T.name
|
||||||
|
|
||||||
|
Base.pr
|
||||||
|
Child.pr
|
||||||
|
|
||||||
|
Base.me
|
||||||
|
when false:
|
||||||
|
Child.me #<- bug #2710
|
||||||
|
|
||||||
|
for s in Base.it: echo s
|
||||||
|
for s in Child.it: echo s #<- bug #2662
|
||||||
Loading…
Add table
Add a link
Reference in a new issue