close #2018
This commit is contained in:
parent
f8c921dd25
commit
d16557bbdb
1 changed files with 17 additions and 2 deletions
|
|
@ -2,7 +2,9 @@ discard """
|
||||||
output: '''true
|
output: '''true
|
||||||
true
|
true
|
||||||
true
|
true
|
||||||
true'''
|
true
|
||||||
|
p has been called.
|
||||||
|
p has been called.'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# https://github.com/nim-lang/Nim/issues/1147
|
# https://github.com/nim-lang/Nim/issues/1147
|
||||||
|
|
@ -15,7 +17,7 @@ proc add*(self: var TTest, val: int) =
|
||||||
type CAddable = concept x
|
type CAddable = concept x
|
||||||
x[].add(int)
|
x[].add(int)
|
||||||
|
|
||||||
echo((ref TTest) is CAddable)
|
echo((ref TTest) is CAddable) # true
|
||||||
|
|
||||||
# https://github.com/nim-lang/Nim/issues/1570
|
# https://github.com/nim-lang/Nim/issues/1570
|
||||||
type ConcretePointOfFloat = object
|
type ConcretePointOfFloat = object
|
||||||
|
|
@ -34,3 +36,16 @@ echo p1 is AbstractPointOfFloat # true
|
||||||
echo p2 is AbstractPointOfFloat # true
|
echo p2 is AbstractPointOfFloat # true
|
||||||
echo p2.x is float and p2.y is float # true
|
echo p2.x is float and p2.y is float # true
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/issues/2018
|
||||||
|
type ProtocolFollower = generic
|
||||||
|
true # not a particularly involved protocol
|
||||||
|
|
||||||
|
type ImplementorA = object
|
||||||
|
type ImplementorB = object
|
||||||
|
|
||||||
|
proc p[A: ProtocolFollower, B: ProtocolFollower](a: A, b: B) =
|
||||||
|
echo "p has been called."
|
||||||
|
|
||||||
|
p(ImplementorA(), ImplementorA())
|
||||||
|
p(ImplementorA(), ImplementorB())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue