mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 23:35:22 +00:00
implemented procCall builtin
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
discard """
|
||||
file: "tmultim2.nim"
|
||||
output: "collide: unit, thing collide: unit, thing collide: thing, unit"
|
||||
output: '''collide: unit, thing
|
||||
collide: unit, thing
|
||||
collide: thing, unit
|
||||
collide: thing, thing'''
|
||||
"""
|
||||
# Test multi methods
|
||||
|
||||
@@ -12,25 +15,25 @@ type
|
||||
a, b: int
|
||||
|
||||
method collide(a, b: TThing) {.inline.} =
|
||||
quit "to override!"
|
||||
echo "collide: thing, thing"
|
||||
|
||||
method collide(a: TThing, b: TUnit) {.inline.} =
|
||||
write stdout, "collide: thing, unit "
|
||||
echo "collide: thing, unit"
|
||||
|
||||
method collide(a: TUnit, b: TThing) {.inline.} =
|
||||
write stdout, "collide: unit, thing "
|
||||
echo "collide: unit, thing"
|
||||
|
||||
proc test(a, b: TThing) {.inline.} =
|
||||
collide(a, b)
|
||||
|
||||
proc staticCollide(a, b: TThing) {.inline.} =
|
||||
procCall collide(a, b)
|
||||
|
||||
|
||||
var
|
||||
a: TThing
|
||||
b, c: TUnit
|
||||
collide(b, c) # ambiguous (unit, thing) or (thing, unit)? -> prefer unit, thing!
|
||||
test(b, c)
|
||||
collide(a, b)
|
||||
#OUT collide: unit, thing collide: unit, thing collide: thing, unit
|
||||
|
||||
|
||||
|
||||
|
||||
staticCollide(a, b)
|
||||
|
||||
Reference in New Issue
Block a user