summaryrefslogtreecommitdiff
path: root/09-implicit-parameters-and-views.md
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 17:36:31 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 17:36:31 -0700
commit84bba26776a76252a4576947adc15364f5ae8e55 (patch)
tree282dd231d82fe1a7ad12df3d3c6d7c9be205440e /09-implicit-parameters-and-views.md
parent227e11d9a8f16ae551f9cc2c81c12c93f8c50175 (diff)
downloadscala-84bba26776a76252a4576947adc15364f5ae8e55.tar.gz
scala-84bba26776a76252a4576947adc15364f5ae8e55.tar.bz2
scala-84bba26776a76252a4576947adc15364f5ae8e55.zip
SI-5089 update definition implicit scope in terms of parts of a type
add note that implicits in package objects are not a good idea
Diffstat (limited to '09-implicit-parameters-and-views.md')
-rw-r--r--09-implicit-parameters-and-views.md40
1 files changed, 22 insertions, 18 deletions
diff --git a/09-implicit-parameters-and-views.md b/09-implicit-parameters-and-views.md
index a88ebbc069..c6ee335f55 100644
--- a/09-implicit-parameters-and-views.md
+++ b/09-implicit-parameters-and-views.md
@@ -61,24 +61,28 @@ identifiers under this rule, then, second, eligible are also all
`implicit` members of some object that belongs to the implicit
scope of the implicit parameter's type, $T$.
-The _implicit scope_ of a type $T$ consists of all
-[companion modules](#object-definitions)
-of classes that are associated with the
-implicit parameter's type. Here, we say a class $C$ is
-_associated_ with a type $T$, if it is a [base class](#class-linearization)
-of some part of $T$. The _parts_ of a type $T$ are:
-
-
-* if $T$ is a compound type `$T_1$ with $\ldots$ with $T_n$`, the
- union of the parts of $T_1 , \ldots , T_n$, as well as $T$ itself,
-* if $T$ is a parameterized type `$S$[$T_1 , \ldots , T_n$]`,
- the union of the parts of $S$ and $T_1 , \ldots , T_n$,
-* if $T$ is a singleton type `$p$.type`, the parts of the type
- of $p$,
-* if $T$ is a type projection `$S$#$U$`, the parts of $S$ as
- well as $T$ itself,
-* in all other cases, just $T$ itself.
-
+The _implicit scope_ of a type $T$ consists of all [companion modules](#object-definitions) of classes that are associated with the implicit parameter's type.
+Here, we say a class $C$ is _associated_ with a type $T$ if it is a [base class](#class-linearization) of some part of $T$.
+
+The _parts_ of a type $T$ are:
+
+- if $T$ is a compound type `$T_1$ with $\ldots$ with $T_n$`,
+ the union of the parts of $T_1 , \ldots , T_n$, as well as $T$ itself;
+- if $T$ is a parameterized type `$S$[$T_1 , \ldots , T_n$]`,
+ the union of the parts of $S$ and $T_1 , \ldots , T_n$;
+- if $T$ is a singleton type `$p$.type`,
+ the parts of the type of $p$;
+- if $T$ is a type projection `$S$#$U$`,
+ the parts of $S$ as well as $T$ itself;
+- if $T$ is a type alias, the parts of its expansion;
+- if $T$ is an abstract type, the parts of its upper bound;
+- if $T$ denotes an implicit conversion to a type with a method with argument types $T_1 , \ldots , T_n$ and result type $U$,
+ the union of the parts of $T_1 , \ldots , T_n$ and $U$;
+- the parts of quantified (existential or univeral) and annotated types are defined as the parts of the underlying types (e.g., the parts of `T forSome { ... }` are the parts of `T`);
+- in all other cases, just $T$ itself.
+
+Note that packages are internally represented as classes with companion modules to hold the package members.
+Thus, implicits defined in a package object are part of the implicit scope of a type prefixed by that package.
If there are several eligible arguments which match the implicit
parameter's type, a most specific one will be chosen using the rules