File tree Expand file tree Collapse file tree 2 files changed +37
-18
lines changed Expand file tree Collapse file tree 2 files changed +37
-18
lines changed Original file line number Diff line number Diff line change 1313method wow [T](y: int ; x: First [T]) {.base .} =
1414 echo " wow1"
1515
16+ when defined (nimLazySemcheck):
17+ # this currently needs the following workaround; note that generic methods
18+ # are deprecated and non-generic methods work fine, see D20210909T005449
19+ type _ = typeof (wow) # D20210905T125411_forceSemcheck_compiles
20+
1621method wow [T](y: int ; x: Second [T]) =
1722 echo " wow2"
1823
Original file line number Diff line number Diff line change @@ -33,24 +33,38 @@ when defined case_noimports:
3333 static : doAssert gfn1 () == 2
3434 doAssert gfn1 () == 2
3535
36- # method
37- type Ga = ref object of RootObj
38- method gfn2 * (a: Ga , b: string ) {.base , gcsafe .} = discard
39- block :
40- var a = Ga ()
41- a.gfn2 (" " )
42-
43- # converter
44- type Ga3 = object
45- a0: int
46- type Gb3 = object
47- b0: int
48- converter toGb3 (a: Ga3 ): Gb3 =
49- Gb3 (b0: a.a0)
50- block :
51- var a = Ga3 (a0: 3 )
52- var b: Gb3 = a
53- doAssert b == Gb3 (b0: 3 )
36+ when true : # methods
37+ type Ga = ref object of RootObj
38+ method gfn2 * (a: Ga , b: string ) {.base , gcsafe .} = discard
39+ block :
40+ var a = Ga ()
41+ a.gfn2 (" " )
42+
43+ # D20210909T005449:here
44+ # example adapted from tests/method/tgeneric_methods but using regular methods
45+ # instead of generic methods (which are deprecated)
46+ type
47+ GFirst = ref object of RootObj
48+ value: int
49+ GSecond = ref object of GFirst
50+ value2: int
51+ method wow (x: GFirst ): int {.base .} = 1
52+ method wow (x: GSecond ): int = 2
53+ block :
54+ proc takeFirst (x: GFirst ): int = wow (x)
55+ doAssert takeFirst (GSecond ()) == 2
56+
57+ when true : # converter
58+ type Ga3 = object
59+ a0: int
60+ type Gb3 = object
61+ b0: int
62+ converter toGb3 (a: Ga3 ): Gb3 =
63+ Gb3 (b0: a.a0)
64+ block :
65+ var a = Ga3 (a0: 3 )
66+ var b: Gb3 = a
67+ doAssert b == Gb3 (b0: 3 )
5468
5569 block : # out of order
5670 proc fn1 =
You can’t perform that action at this time.
0 commit comments