-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
I think this might not be a comprehensive solution to dealing with `tyGenericBody` but we take a step forward #24451
- Loading branch information
Showing
2 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
discard """ | ||
action: "run" | ||
output: ''' | ||
B[system.int] | ||
A[system.string] | ||
''' | ||
""" | ||
|
||
block: # issue #24451 | ||
type | ||
A = object | ||
x: int | ||
B[T] = object | ||
b: T | ||
AConcept = concept | ||
proc implementation(s: var Self, p1: B[int]) | ||
|
||
proc implementation(r: var A, p1: B[int])= | ||
echo typeof(p1) | ||
|
||
proc accept(r: var AConcept)= | ||
r.implementation(B[int]()) | ||
|
||
var a = A() | ||
a.accept() | ||
|
||
block: # typeclass | ||
type | ||
A[T] = object | ||
x: int | ||
AConcept = concept | ||
proc implementation(s: Self) | ||
|
||
proc implementation(r: A) = | ||
echo typeof(r) | ||
|
||
proc accept(r: AConcept) = | ||
r.implementation() | ||
|
||
var a = A[string]() | ||
a.accept() |