This is an error in an implicit search.
Here is the same structure in more normal code where the execution context is required implicitly.
(It does not matter whether importing a wildcard from a package object or another package is in the same compilation unit.)
Since the code compiles with explicit global , it must compile with the implicit arg argument.
Implicit is available if it can be accessed without a prefix .
The priority of the binding does not depend on the order of the source code. Shadow works in the usual way; a binding never obscures a higher priority binding.
/* package object bound2 { implicit lazy val global = scala.concurrent.ExecutionContext.Implicits.global } */ package bound2 { object B { implicit lazy val global: concurrent.ExecutionContextExecutor = scala.concurrent.ExecutionContext.global } } package bound { // the order of these imports in the same scope should not matter import scala.concurrent.ExecutionContext.Implicits.global import bound2.B._ object Test extends App { val f = concurrent.Future(42) //(global) // explicit arg works Console println concurrent.Await.result(f, concurrent.duration.Duration.Inf) } }
In the sample specification 2.0.1, a line labeled “OK” is added, and you can verify that the order does not matter, but it becomes ambiguous in the inner scope because the “wildcard y” does not obscure “Explicit y” from external area:
import Xy // `y' bound by explicit import println("L16: "+y) // `y' refers to `QXy' here import PX_ println("OK: "+y) // `y' refers to `QXy' here locally { val x = "abc" // `x' bound by local definition import PX_ // `x' and `y' bound by wildcard import // println("L19: "+y) // reference to `y' is ambiguous here
som-snytt
source share