Restore the Nim's 0.14 proper handling of generic aliases
A more efficient implementation is possible by restoring the old lifting ot tyGenericInvocation to tyGenericInst in liftTypeParam, but this fix will suffice for now. fixes #5087 fixes #5602 fixes #5641 fixes #5570
This commit is contained in:
parent
fceef77301
commit
e9a3ffbc3d
12 changed files with 236 additions and 55 deletions
27
tests/generics/t5570.nim
Normal file
27
tests/generics/t5570.nim
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
discard """
|
||||
nimout: "type uint32\ntype uint32"
|
||||
output: "(weight: 17.0, color: 100)"
|
||||
"""
|
||||
|
||||
import macros
|
||||
|
||||
type
|
||||
BaseFruit[T] = object of RootObj
|
||||
color: T
|
||||
|
||||
Banana[T] = object of BaseFruit[uint32]
|
||||
weight: T
|
||||
|
||||
macro printTypeName(typ: typed): untyped =
|
||||
echo "type ", getType(typ).repr
|
||||
|
||||
proc setColor[K](self: var BaseFruit[K], c: int) =
|
||||
printTypeName(self.color)
|
||||
self.color = uint32(c)
|
||||
|
||||
var x: Banana[float64]
|
||||
x.weight = 17
|
||||
printTypeName(x.color)
|
||||
x.setColor(100)
|
||||
echo x
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue