fix typos and deprecation warnings for tconvariancerules.nim (#13772)
This commit is contained in:
parent
289b31ee75
commit
142c59fc37
1 changed files with 20 additions and 21 deletions
|
|
@ -28,9 +28,9 @@ template reject(x) =
|
||||||
|
|
||||||
import macros
|
import macros
|
||||||
|
|
||||||
macro skipElse(n: untyped): typed = n[0]
|
macro skipElse(n: untyped): untyped = n[0]
|
||||||
|
|
||||||
template acceptWithCovariance(x, otherwise): typed =
|
template acceptWithCovariance(x, otherwise): untyped =
|
||||||
when nimEnableCovariance:
|
when nimEnableCovariance:
|
||||||
x
|
x
|
||||||
else:
|
else:
|
||||||
|
|
@ -79,16 +79,16 @@ proc wantsCovariantSeq2(s: seq[AnimalRef]) =
|
||||||
proc wantsCovariantSeq3(s: seq[RefAlias[Animal]]) =
|
proc wantsCovariantSeq3(s: seq[RefAlias[Animal]]) =
|
||||||
for a in s: echo a.x
|
for a in s: echo a.x
|
||||||
|
|
||||||
proc wantsCovariantOperArray(s: openarray[ref Animal]) =
|
proc wantsCovariantOpenArray(s: openarray[ref Animal]) =
|
||||||
for a in s: echo a.x
|
for a in s: echo a.x
|
||||||
|
|
||||||
proc modifiesCovariantOperArray(s: var openarray[ref Animal]) =
|
proc modifiesCovariantOpenArray(s: var openarray[ref Animal]) =
|
||||||
for a in s: echo a.x
|
for a in s: echo a.x
|
||||||
|
|
||||||
proc modifiesDerivedOperArray(s: var openarray[ref Dog]) =
|
proc modifiesDerivedOpenArray(s: var openarray[ref Dog]) =
|
||||||
for a in s: echo a.x
|
for a in s: echo a.x
|
||||||
|
|
||||||
proc wantsNonCovariantOperArray(s: openarray[Animal]) =
|
proc wantsNonCovariantOpenArray(s: openarray[Animal]) =
|
||||||
for a in s: echo a.x
|
for a in s: echo a.x
|
||||||
|
|
||||||
proc wantsCovariantArray(s: array[2, ref Animal]) =
|
proc wantsCovariantArray(s: array[2, ref Animal]) =
|
||||||
|
|
@ -199,15 +199,15 @@ accept:
|
||||||
wantsCovariantSeq3(@[AnimalRef(cat), dog])
|
wantsCovariantSeq3(@[AnimalRef(cat), dog])
|
||||||
wantsCovariantSeq3(@[cat, dog])
|
wantsCovariantSeq3(@[cat, dog])
|
||||||
|
|
||||||
wantsCovariantOperArray([cat, dog])
|
wantsCovariantOpenArray([cat, dog])
|
||||||
|
|
||||||
acceptWithCovariance:
|
acceptWithCovariance:
|
||||||
wantsCovariantSeq1(@[cat, cat])
|
wantsCovariantSeq1(@[cat, cat])
|
||||||
wantsCovariantSeq2(@[dog, makeDerivedRef("dog X")])
|
wantsCovariantSeq2(@[dog, makeDerivedRef("dog X")])
|
||||||
# XXX: wantsCovariantSeq3(@[cat, cat])
|
# XXX: wantsCovariantSeq3(@[cat, cat])
|
||||||
|
|
||||||
wantsCovariantOperArray(@[cat, cat])
|
wantsCovariantOpenArray(@[cat, cat])
|
||||||
wantsCovariantOperArray([dog, dog])
|
wantsCovariantOpenArray([dog, dog])
|
||||||
else:
|
else:
|
||||||
echo "cat"
|
echo "cat"
|
||||||
echo "cat"
|
echo "cat"
|
||||||
|
|
@ -226,7 +226,7 @@ accept:
|
||||||
modifiesDerivedArray(dogRefsArray)
|
modifiesDerivedArray(dogRefsArray)
|
||||||
modifiesDerivedSeq(dogRefs)
|
modifiesDerivedSeq(dogRefs)
|
||||||
|
|
||||||
reject modifiesCovariantSeq(dogRefs)
|
reject modifiesCovariantSeqd(ogRefs)
|
||||||
reject modifiesCovariantSeq(addr(dogRefs))
|
reject modifiesCovariantSeq(addr(dogRefs))
|
||||||
reject modifiesCovariantSeq(dogRefs.addr)
|
reject modifiesCovariantSeq(dogRefs.addr)
|
||||||
|
|
||||||
|
|
@ -245,19 +245,19 @@ when false:
|
||||||
wantsNonCovariantArray animalValuesArray
|
wantsNonCovariantArray animalValuesArray
|
||||||
|
|
||||||
reject wantsNonCovariantSeq(dogRefs)
|
reject wantsNonCovariantSeq(dogRefs)
|
||||||
reject modifiesCovariantOperArray(dogRefs)
|
reject modifiesCovariantOpenArray(dogRefs)
|
||||||
reject wantsNonCovariantArray(dogRefsArray)
|
reject wantsNonCovariantArray(dogRefsArray)
|
||||||
reject wantsNonCovariantSeq(dogValues)
|
reject wantsNonCovariantSeq(dogValues)
|
||||||
reject wantsNonCovariantArray(dogValuesArray)
|
reject wantsNonCovariantArray(dogValuesArray)
|
||||||
reject modifiesValueArray()
|
reject modifiesValueArray()
|
||||||
|
|
||||||
modifiesDerivedOperArray dogRefs
|
modifiesDerivedOpenArray dogRefs
|
||||||
reject modifiesDerivedOperArray(dogValues)
|
reject modifiesDerivedOpenArray(dogValues)
|
||||||
reject modifiesDerivedOperArray(animalRefs)
|
reject modifiesDerivedOpenArray(animalRefs)
|
||||||
|
|
||||||
reject wantsNonCovariantOperArray(animalRefs)
|
reject wantsNonCovariantOpenArray(animalRefs)
|
||||||
reject wantsNonCovariantOperArray(dogRefs)
|
reject wantsNonCovariantOpenArray(dogRefs)
|
||||||
reject wantsNonCovariantOperArray(dogValues)
|
reject wantsNonCovariantOpenArray(dogValues)
|
||||||
|
|
||||||
var animalRefSeq: seq[ref Animal]
|
var animalRefSeq: seq[ref Animal]
|
||||||
|
|
||||||
|
|
@ -300,12 +300,12 @@ template <class T> struct ARR { typedef T DataType[2]; DataType data; };
|
||||||
""".}
|
""".}
|
||||||
|
|
||||||
type
|
type
|
||||||
MyPtr {.importcpp: "'0 *"} [out T] = object
|
MyPtr[out T] {.importcpp: "'0 *"} = object
|
||||||
|
|
||||||
MySeq {.importcpp: "ARR<'0>", nodecl} [out T] = object
|
MySeq[out T] {.importcpp: "ARR<'0>", nodecl} = object
|
||||||
data: array[2, T]
|
data: array[2, T]
|
||||||
|
|
||||||
MyAction {.importcpp: "FN<'0>::type"} [in T] = object
|
MyAction[in T] {.importcpp: "FN<'0>::type"} = object
|
||||||
|
|
||||||
var
|
var
|
||||||
cAnimal: MyPtr[Animal]
|
cAnimal: MyPtr[Animal]
|
||||||
|
|
@ -415,4 +415,3 @@ reject usesAddressOfAnimalRefSeq(addr cAnimalValues)
|
||||||
reject usesAddressOfAnimalRefSeq(addr cDogValues)
|
reject usesAddressOfAnimalRefSeq(addr cDogValues)
|
||||||
accept usesAddressOfAnimalRefSeq(addr cAnimals)
|
accept usesAddressOfAnimalRefSeq(addr cAnimals)
|
||||||
reject usesAddressOfAnimalRefSeq(addr cDogs)
|
reject usesAddressOfAnimalRefSeq(addr cDogs)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue