New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scalac sometimes ignores companion implicits #7291
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7291?orig=1 |
@xeno-by said (edited on Mar 24, 2013 10:41:52 AM UTC): 11:40 ~/Projects/Master/sandbox (master)$ scalad Test.scala -Xprint:typer
Initial compilation of sources...
[[syntax trees at end of typer]] // Test.scala
package <empty> {
abstract trait Fooable[T >: Nothing <: Any] extends scala.AnyRef;
object Fooable extends scala.AnyRef {
def <init>(): Fooable.type = {
Fooable.super.<init>();
()
};
implicit def conjure[T >: Nothing <: Any]: Fooable[T] = {
scala.this.Predef.println("conjure");
{
final class $anon extends AnyRef with Fooable[T] {
def <init>(): anonymous class $anon = {
$anon.super.<init>();
()
};
<empty>
};
new $anon()
}
}
};
object Test extends AnyRef with App {
def <init>(): Test.type = {
Test.super.<init>();
()
};
implicit def traversable[T >: Nothing <: Any, Coll[_ >: Nothing <: Any] >: [_]Nothing <: [_]Traversable[_]](implicit elem: Fooable[T]): Fooable[Coll[T]] = {
scala.this.Predef.println("traversable");
{
final class $anon extends AnyRef with Fooable[Coll[T]] {
def <init>(): anonymous class $anon = {
$anon.super.<init>();
()
};
<empty>
};
new $anon()
}
};
scala.this.Predef.implicitly[Fooable[List[Any]]](Test.this.traversable[Any, List](Fooable.conjure[Any]))
}
}
Initial compilation finished. Starting UI... |
@xeno-by said: |
@xeno-by said: |
@hubertp said: |
@hubertp said: |
@xeno-by said: |
@xeno-by said: |
Michael Khan (michael.khan) said (edited on Feb 5, 2016 11:10:06 AM UTC): I have a case class with an associated companion class defined in a domains package (Play project) as follows: case class Registration(serviceName: String, serviceUrl: String, metadata: Option[Map[String, String]] = None) object Registration { We have a custom HTTP library we have built for our organisation which allows us to make HTTP calls - it is publicly available here (https://github.com/hmrc/http-verbs). The following call is made:
where the second parameter is of type Registration. When compiling the compiler complains as follows:
When I explicitly import the companion object into the same translation unit where this http.POST method is called, the compiler is able to pick up the implicit and compilation is a success. If I don't, then it complains about diverging implicit expansion error. |
This particular example has worked in the modern era, the |
Should print "conjure", then "traversable". Currently it prints just "conjure". Details: http://groups.google.com/group/scala-internals/browse_thread/thread/f284df8ee19c2aba
The text was updated successfully, but these errors were encountered: