C# Language Specification



Download 0,75 Mb.
bet191/524
Sana06.01.2022
Hajmi0,75 Mb.
#324842
1   ...   187   188   189   190   191   192   193   194   ...   524
Bog'liq
CSharp Language Specification

Upper-bound inferences


An upper-bound inference from a type U to a type V is made as follows:

  • If V is one of the unfixed Xi then U is added to the set of upper bounds for Xi.

  • Otherwise, sets V1…Vk and U1…Uk are determined by checking if any of the following cases apply:

  • U is an array type U1[…]and V is an array type V1[…]of the same rank

  • U is one of IEnumerablee>, ICollectione> or IListe> and V is a one-dimensional array type Ve[]

  • U is the type U1? and V is the type V1?

  • U is constructed class, struct, interface or delegate type C1…Uk> and V is a class, struct, interface or delegate type which is identical to, inherits from (directly or indirectly), or implements (directly or indirectly) a unique type C1…Vk>

(The “uniqueness” restriction means that if we have interface C{} class V: C>, C>{}, then no inference is made when inferring from C1> to V. Inferences are not made from U1 to either X or Y.)

If any of these cases apply then an inference is made from each Ui to the corresponding Vi as follows:



  • If Ui is not known to be a reference type then an exact inference is made

  • Otherwise, if V is an array type then an upper-bound inference is made

  • Otherwise, if U is C1…Uk> then inference depends on the i-th type parameter of C:

  • If it is covariant then an upper-bound inference is made.

  • If it is contravariant then a lower-bound inference is made.

  • If it is invariant then an exact inference is made.

  • Otherwise, no inferences are made.
        1. Fixing


An unfixed type variable Xi with a set of bounds is fixed as follows:

  • The set of candidate types Uj starts out as the set of all types in the set of bounds for Xi.

  • We then examine each bound for Xi in turn: For each exact bound U of Xi all types Uj which are not identical to U are removed from the candidate set. For each lower bound U of Xi all types Uj to which there is not an implicit conversion from U are removed from the candidate set. For each upper bound U of Xi all types Uj from which there is not an implicit conversion to U are removed from the candidate set.

  • If among the remaining candidate types Uj there is a unique type V from which there is an implicit conversion to all the other candidate types, then Xi is fixed to V.

  • Otherwise, type inference fails.

        1. Download 0,75 Mb.

          Do'stlaringiz bilan baham:
1   ...   187   188   189   190   191   192   193   194   ...   524




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish