Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
java_language_specification_7.pdf
Скачиваний:
13
Добавлен:
21.03.2016
Размер:
3.11 Mб
Скачать

EXPRESSIONS

Compile-Time Step 2: Determine Method Signature 15.12.2

where glb() is as defined in §5.1.10.

Finally, we define a bound for Tj based on on all the elements of the minimal erased candidate set of its supertypes. If any of these elements are generic, we use the CandidateInvocation() function to recover the type argument information.

Define Candidate(W) = CandidateInvocation(W) if W is generic, W otherwise.

The inferred type for Tj, lub(U1 ... Uk), is Candidate(W1) & ... & Candidate(Wr), where Wi (1 i r) are the elements of MEC.

It is possible that the process above yields an infinite type. This is permissible, and a Java compiler must recognize such situations and represent them appropriately using cyclic data structures.

The possibility of an infinite type stems from the recursive calls to lub(). Readers familiar with recursive types should note that an infinite type is not the same as a recursive type.

15.12.2.8 Inferring Unresolved Type Arguments

If any of the method's type arguments were not inferred from the types of the actual arguments, they are now inferred as follows.

If the method result occurs in a context where it will be subject to assignment conversion (§5.2) to a type S, then let R be the declared result type of the method, and let R' = R[T1=B(T1) ... Tn=B(Tn)], where B(Ti) is the type inferred for Ti in the previous section or Ti if no type was inferred.

If S is a reference type, then let S' be S. Otherwise, if S is a primitive type, then let S' be the result of applying boxing conversion (§5.1.7) to S.

Then, a set of initial constraints consisting of:

the constraint S' >> R', provided R is not void; and

additional constraints Bi[T1=B(T1) ... Tn=B(Tn)] >> Ti, where Bi is the declared bound of Ti,

additional constraints B(Ti) << Bi[T1=B(T1) ... Tn=B(Tn)], where Bi is the declared bound of Ti,

for any constraint of the form V >> Ti generated in §15.12.2.7: a constraint

V[T1=B(T1) ... Tn=B(Tn)] >> Ti.

for any constraint of the form Ti = V generated in §15.12.2.7: a constraint Ti = V[T1=B(T1) ... Tn=B(Tn)].

477

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]