You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the Manifest bound and the following code compiles, inferring the type argument to A to be Int. With the Manifest bound, it does not compile because the type argument to A is inferred to be Nothing.
@adriaanm said (edited on Jun 15, 2011 10:47:36 AM UTC):
I'm afraid this is an enhancement rather than a bug. Implicit views and implicit search do not chain this way. In the version with the manifest bound, the A("a") must be fully adapted (i.e., the implicit value for the manifest found), before the rest of the expression is even considered.
When you remove the manifest bound, the T type parameter survives as an undetermined type parameter until the x method call is type checked and its argument determines T to be Int. However, we don't delay the manifest search in the same way (though technically we could -- afaik, the spec is silent on the details).
The "delayed manifest search" interpretation would be more complicated to implement, as I think it would require the context tracking undetermined manifests along with the undetermined type parameters.
The implicit search for Manifest[T] and Z[T] are different in the sense that the qq implicit determines the T type parameter, whereas the manifest cannot be determined until the x method call has been type checked fully.
Concretely, the version with the manifest is more precisely approximated by
Remove the Manifest bound and the following code compiles, inferring the type argument to A to be Int. With the Manifest bound, it does not compile because the type argument to A is inferred to be Nothing.
The error message is:
Changing Manifest to be another type constructor with an implicit in scope compiles:
as does making the type parameter to A and V covariant:
Unfortunately, I cannot make the type parameter for A covariant in the actual code.
The text was updated successfully, but these errors were encountered: