mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fix typos and deprecation warnings for tconvariancerules.nim (#13772)
This commit is contained in:
@@ -28,9 +28,9 @@ template reject(x) =
|
||||
|
||||
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:
|
||||
x
|
||||
else:
|
||||
@@ -79,16 +79,16 @@ proc wantsCovariantSeq2(s: seq[AnimalRef]) =
|
||||
proc wantsCovariantSeq3(s: seq[RefAlias[Animal]]) =
|
||||
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
|
||||
|
||||
proc modifiesCovariantOperArray(s: var openarray[ref Animal]) =
|
||||
proc modifiesCovariantOpenArray(s: var openarray[ref Animal]) =
|
||||
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
|
||||
|
||||
proc wantsNonCovariantOperArray(s: openarray[Animal]) =
|
||||
proc wantsNonCovariantOpenArray(s: openarray[Animal]) =
|
||||
for a in s: echo a.x
|
||||
|
||||
proc wantsCovariantArray(s: array[2, ref Animal]) =
|
||||
@@ -199,15 +199,15 @@ accept:
|
||||
wantsCovariantSeq3(@[AnimalRef(cat), dog])
|
||||
wantsCovariantSeq3(@[cat, dog])
|
||||
|
||||
wantsCovariantOperArray([cat, dog])
|
||||
wantsCovariantOpenArray([cat, dog])
|
||||
|
||||
acceptWithCovariance:
|
||||
wantsCovariantSeq1(@[cat, cat])
|
||||
wantsCovariantSeq2(@[dog, makeDerivedRef("dog X")])
|
||||
# XXX: wantsCovariantSeq3(@[cat, cat])
|
||||
|
||||
wantsCovariantOperArray(@[cat, cat])
|
||||
wantsCovariantOperArray([dog, dog])
|
||||
wantsCovariantOpenArray(@[cat, cat])
|
||||
wantsCovariantOpenArray([dog, dog])
|
||||
else:
|
||||
echo "cat"
|
||||
echo "cat"
|
||||
@@ -226,7 +226,7 @@ accept:
|
||||
modifiesDerivedArray(dogRefsArray)
|
||||
modifiesDerivedSeq(dogRefs)
|
||||
|
||||
reject modifiesCovariantSeq(dogRefs)
|
||||
reject modifiesCovariantSeqd(ogRefs)
|
||||
reject modifiesCovariantSeq(addr(dogRefs))
|
||||
reject modifiesCovariantSeq(dogRefs.addr)
|
||||
|
||||
@@ -245,19 +245,19 @@ when false:
|
||||
wantsNonCovariantArray animalValuesArray
|
||||
|
||||
reject wantsNonCovariantSeq(dogRefs)
|
||||
reject modifiesCovariantOperArray(dogRefs)
|
||||
reject modifiesCovariantOpenArray(dogRefs)
|
||||
reject wantsNonCovariantArray(dogRefsArray)
|
||||
reject wantsNonCovariantSeq(dogValues)
|
||||
reject wantsNonCovariantArray(dogValuesArray)
|
||||
reject modifiesValueArray()
|
||||
|
||||
modifiesDerivedOperArray dogRefs
|
||||
reject modifiesDerivedOperArray(dogValues)
|
||||
reject modifiesDerivedOperArray(animalRefs)
|
||||
modifiesDerivedOpenArray dogRefs
|
||||
reject modifiesDerivedOpenArray(dogValues)
|
||||
reject modifiesDerivedOpenArray(animalRefs)
|
||||
|
||||
reject wantsNonCovariantOperArray(animalRefs)
|
||||
reject wantsNonCovariantOperArray(dogRefs)
|
||||
reject wantsNonCovariantOperArray(dogValues)
|
||||
reject wantsNonCovariantOpenArray(animalRefs)
|
||||
reject wantsNonCovariantOpenArray(dogRefs)
|
||||
reject wantsNonCovariantOpenArray(dogValues)
|
||||
|
||||
var animalRefSeq: seq[ref Animal]
|
||||
|
||||
@@ -300,12 +300,12 @@ template <class T> struct ARR { typedef T DataType[2]; DataType data; };
|
||||
""".}
|
||||
|
||||
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]
|
||||
|
||||
MyAction {.importcpp: "FN<'0>::type"} [in T] = object
|
||||
MyAction[in T] {.importcpp: "FN<'0>::type"} = object
|
||||
|
||||
var
|
||||
cAnimal: MyPtr[Animal]
|
||||
@@ -415,4 +415,3 @@ reject usesAddressOfAnimalRefSeq(addr cAnimalValues)
|
||||
reject usesAddressOfAnimalRefSeq(addr cDogValues)
|
||||
accept usesAddressOfAnimalRefSeq(addr cAnimals)
|
||||
reject usesAddressOfAnimalRefSeq(addr cDogs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user