Aladdin - Scala Bugtracking
[#721] project: specification priority: medium category: bug
submitter assigned to status date submitted
Gilles Martin fixed 2006-09-01 15:33:33.0
subject Views lookup scope is ill-defined (see also #720)
code
what happened
In the Scala reference, chapter "views" (7.3) the lookup rules for views are not understandable by a Gilles. It \
states that, to be applied, "the view must be denotable by a single identifier at the point for the application"\
 (which is OK) "or else it must be a member of some companion module of the type [expression type => expe\
cted type]". The exact companion module scope bounded by "some" is not precise enough. Same problem is true for \
the other view case.
what expected

Solution depends on what is implemented exactly (see bug #720). What I would like to read (and have implemented) for chapter 7.3 is:

Implicit parameters and methods can also define implicit conversions called views. A view from type S to type T is defined by an implicit value which has a type compatible with function type S=>T, or by a method convertible to a value of such a type.

Views are applied in two situations.

  1. If an expression e is of type S, and S does not conform to the expression’s expected type T. In this case, a view v from type S to type T is searched in the view scope (c.f. infra) for e, S and T (in that order).
  2. In a selection e.m with e of type S, if the selector m does not denote a member of S. In this case, a view v from type S to type T where T is any class type containing a member called m is searched in the view scope (c.f. infra) for e and S (in that order).

The view scope for an expression e is composed of all implicit members denotable by a single identifier in e. The view scope for a type T is composed of all implicit members of the companion modules of all classes associated with T.

...

[back to overview]
Changes of this bug report
Gilles  edited on  2006-09-01 15:36:08.0
Martin  edited on  2006-09-04 16:35:44.0