% cat sandbox/test.scala && scalac-hash v2.11.4 -Dscala.color -Ytyper-debug -Xprint:typer sandbox/test.scala
class Insert[I, O](arg: I)
object Test {
def execute[I,O](req: Insert[I,O]): O = null.asInstanceOf[O]
val result: Int = execute(new Insert("test"))
}
|-- <empty> EXPRmode-POLYmode-QUALmode (site: package <root>)
| \-> <empty>.type
|-- class Insert[I, O] BYVALmode-EXPRmode (site: package <empty>)
| |-- I TYPEmode (site: value arg in <empty>)
| | \-> I
| |-- I BYVALmode-EXPRmode (site: class Insert)
| | \-> [val arg] I
| |-- def <init> BYVALmode-EXPRmode (site: class Insert)
| | |-- I TYPEmode (site: value arg in <empty>)
| | | \-> I
| | |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in Insert)
| | | |-- this EXPRmode (silent: <init> in Insert)
| | | | \-> Insert[I,O]
| | | \-> Insert.super.type (with underlying type AnyRef)
| | \-> [def <init>] (arg: I)Insert[I,O]
| \-> [class Insert] Insert[I,O]
|-- object Test BYVALmode-EXPRmode (site: package <empty>)
| |-- Int TYPEmode (site: value result in Test)
| | \-> Int
| |-- Int TYPEmode (site: value result in Test)
| | \-> Int
| |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in Test)
| | |-- this EXPRmode (silent: <init> in Test)
| | | \-> Test.type
| | \-> Test.type
| |-- def execute[I, O] BYVALmode-EXPRmode (site: object Test)
| | |-- O TYPEmode (site: method execute in Test)
| | | \-> O
| | |-- Insert[I, O] TYPEmode (site: value req in Test)
| | | |-- I TYPEmode (site: value req in Test)
| | | | \-> I
| | | |-- O TYPEmode (site: value req in Test)
| | | | \-> O
| | | \-> Insert[I,O]
| | |-- Insert[I,O] TYPEmode (site: value req in Test)
| | | \-> Insert[I,O]
| | |-- null.asInstanceOf[O] : pt=O EXPRmode (site: method execute in Test)
| | | |-- null.asInstanceOf BYVALmode-EXPRmode-FUNmode-POLYmode-TAPPmode (site: method execute in Test)
| | | | |-- null EXPRmode-POLYmode-QUALmode (site: method execute in Test)
| | | | | \-> Null(null)
| | | | \-> [T0]=> T0
| | | |-- O TYPEmode (site: method execute in Test)
| | | | \-> O
| | | \-> O
| | \-> [def execute] [I, O](req: Insert[I,O])O
| |-- Int BYVALmode-EXPRmode (site: object Test)
| | |-- Int TYPEmode (site: value result in Test)
| | | \-> Int
| | |-- execute(new Insert("test")) : pt=Int BYVALmode-EXPRmode (site: value result in Test)
| | | |-- execute BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value result in Test)
| | | | [adapt] [I, O](req: Insert[I,O])O adapted to [I, O](req: Insert[I,O])O
| | | | \-> (req: Insert[I,O])O
| | | |-- new Insert("test") : pt=Insert[?,?] BYVALmode-EXPRmode-POLYmode (site: value result in Test)
| | | | |-- new Insert BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value result in Test)
| | | | | |-- new Insert EXPRmode-POLYmode-QUALmode (silent: value result in Test)
| | | | | | |-- Insert FUNmode-TYPEmode (silent: value result in Test)
| | | | | | | \-> Insert
| | | | | | \-> Insert[I,O]
| | | | | \-> (arg: I)Insert[I,O]
| | | | |-- "test" BYVALmode-EXPRmode-POLYmode (site: value result in Test)
| | | | | \-> String("test")
| | | | solving for (I: ?I, O: ?O)
| | | | \-> Insert[String,O]
| | | [search #1] start `Int`, searching for adaptation to pt=Insert[String,?O] => Insert[I,O] (silent: value result in Test) implicits disabled
| | | [search #2] start `Int`, searching for adaptation to pt=(=> Insert[String,?O]) => Insert[I,O] (silent: value result in Test) implicits disabled
| | | solving for (O: ?O)
| | | solving for (I: ?I, O: ?O)
| | | \-> Nothing
| | \-> [val result ] Int
| |-- def result BYVALmode-EXPRmode (site: object Test)
| | |-- Int : pt=Int EXPRmode (site: value result in Test)
| | | |-- Test.type EXPRmode-POLYmode-QUALmode (site: value result in Test)
| | | | \-> Test.type
| | | \-> Int
| | \-> [def result] => Int
| \-> [object Test] Test.type
[[syntax trees at end of typer]] // test.scala
package <empty> {
class Insert[I, O] extends scala.AnyRef {
<paramaccessor> private[this] val arg: I = _;
def <init>(arg: I): Insert[I,O] = {
Insert.super.<init>();
()
}
};
object Test extends scala.AnyRef {
def <init>(): Test.type = {
Test.super.<init>();
()
};
def execute[I, O](req: Insert[I,O]): O = null.asInstanceOf[O];
private[this] val result: Int = Test.this.execute[String, Nothing](new Insert[String,Nothing]("test"));
<stable> <accessor> def result: Int = Test.this.result
}
}
% subl sandbox/test.scala
% cat sandbox/test.scala && scalac-hash v2.11.4 -Dscala.color -Ytyper-debug -Xprint:typer sandbox/test.scala
trait Ord[A]
object Ord {
implicit def A: Ord[String] = ???
implicit def B: Ord[Int] = ???
}
class Insert[I, O: Ord](arg: I)
object Test {
def execute[I,O](req: Insert[I,O]): O = null.asInstanceOf[O]
val result: Int = execute(new Insert("test"))
}
|-- <empty> EXPRmode-POLYmode-QUALmode (site: package <root>)
| \-> <empty>.type
|-- class Ord[A] BYVALmode-EXPRmode (site: package <empty>)
| \-> [trait Ord] Ord[A]
|-- object Ord BYVALmode-EXPRmode (site: package <empty>)
| |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in Ord)
| | |-- this EXPRmode (silent: <init> in Ord)
| | | \-> Ord.type
| | \-> Ord.type
| |-- def A BYVALmode-EXPRmode (site: object Ord)
| | |-- Ord[String] TYPEmode (site: method A in Ord)
| | | |-- String TYPEmode (site: method A in Ord)
| | | | [adapt] String is now a TypeTree(String)
| | | | \-> String
| | | \-> Ord[String]
| | |-- Ord[A] TYPEmode (site: method A in Ord)
| | | |-- String TYPEmode (site: method A in Ord)
| | | | [adapt] String is now a TypeTree(String)
| | | | \-> String
| | | \-> Ord[String]
| | |-- $qmark$qmark$qmark : pt=Ord[String] EXPRmode (site: method A in Ord)
| | | \-> Nothing
| | \-> [def A] => Ord[String]
| |-- def B BYVALmode-EXPRmode (site: object Ord)
| | |-- Ord[Int] TYPEmode (site: method B in Ord)
| | | |-- Int TYPEmode (site: method B in Ord)
| | | | \-> Int
| | | \-> Ord[Int]
| | |-- Ord[A] TYPEmode (site: method B in Ord)
| | | |-- Int TYPEmode (site: method B in Ord)
| | | | \-> Int
| | | \-> Ord[Int]
| | |-- $qmark$qmark$qmark : pt=Ord[Int] EXPRmode (site: method B in Ord)
| | | \-> Nothing
| | \-> [def B] => Ord[Int]
| \-> [object Ord] Ord.type
|-- class Insert[I, O] BYVALmode-EXPRmode (site: package <empty>)
| |-- I TYPEmode (site: value arg in <empty>)
| | \-> I
| |-- Ord[O] TYPEmode (site: value evidence$1 in <empty>)
| | |-- O TYPEmode (site: value evidence$1 in <empty>)
| | | \-> O
| | \-> Ord[O]
| |-- I BYVALmode-EXPRmode (site: class Insert)
| | \-> [val arg] I
| |-- Ord[O] BYVALmode-EXPRmode (site: class Insert)
| | |-- Ord[A] TYPEmode (site: value evidence$1 in Insert)
| | | \-> Ord[O]
| | \-> [val evidence$1] Ord[O]
| |-- def <init> BYVALmode-EXPRmode (site: class Insert)
| | |-- I TYPEmode (site: value arg in <empty>)
| | | \-> I
| | |-- Ord[O] TYPEmode (site: value evidence$1 in <empty>)
| | | |-- O TYPEmode (site: value evidence$1 in <empty>)
| | | | \-> O
| | | \-> Ord[O]
| | |-- Ord[A] TYPEmode (site: value evidence$1 in <empty>)
| | | \-> Ord[O]
| | |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in Insert)
| | | |-- this EXPRmode (silent: <init> in Insert)
| | | | \-> Insert[I,O]
| | | \-> Insert.super.type (with underlying type AnyRef)
| | \-> [def <init>] (arg: I)(implicit evidence$1: Ord[O])Insert[I,O]
| \-> [class Insert] Insert[I,O]
|-- object Test BYVALmode-EXPRmode (site: package <empty>)
| |-- Int TYPEmode (site: value result in Test)
| | \-> Int
| |-- Int TYPEmode (site: value result in Test)
| | \-> Int
| |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in Test)
| | |-- this EXPRmode (silent: <init> in Test)
| | | \-> Test.type
| | \-> Test.type
| |-- def execute[I, O] BYVALmode-EXPRmode (site: object Test)
| | |-- O TYPEmode (site: method execute in Test)
| | | \-> O
| | |-- Insert[I, O] TYPEmode (site: value req in Test)
| | | |-- I TYPEmode (site: value req in Test)
| | | | \-> I
| | | |-- O TYPEmode (site: value req in Test)
| | | | \-> O
| | | \-> Insert[I,O]
| | |-- Insert[I,O] TYPEmode (site: value req in Test)
| | | \-> Insert[I,O]
| | |-- null.asInstanceOf[O] : pt=O EXPRmode (site: method execute in Test)
| | | |-- null.asInstanceOf BYVALmode-EXPRmode-FUNmode-POLYmode-TAPPmode (site: method execute in Test)
| | | | |-- null EXPRmode-POLYmode-QUALmode (site: method execute in Test)
| | | | | \-> Null(null)
| | | | \-> [T0]=> T0
| | | |-- O TYPEmode (site: method execute in Test)
| | | | \-> O
| | | \-> O
| | \-> [def execute] [I, O](req: Insert[I,O])O
| |-- Int BYVALmode-EXPRmode (site: object Test)
| | |-- Int TYPEmode (site: value result in Test)
| | | \-> Int
| | |-- execute(new Insert("test")) : pt=Int BYVALmode-EXPRmode (site: value result in Test)
| | | |-- execute BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value result in Test)
| | | | [adapt] [I, O](req: Insert[I,O])O adapted to [I, O](req: Insert[I,O])O
| | | | \-> (req: Insert[I,O])O
| | | |-- new Insert("test") : pt=Insert[?,?] BYVALmode-EXPRmode-POLYmode (site: value result in Test)
| | | | |-- new Insert BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value result in Test)
| | | | | |-- new Insert EXPRmode-POLYmode-QUALmode (silent: value result in Test)
| | | | | | |-- Insert FUNmode-TYPEmode (silent: value result in Test)
| | | | | | | \-> Insert
| | | | | | \-> Insert[I,O]
| | | | | \-> (arg: I)(implicit evidence$1: Ord[O])Insert[I,O]
| | | | |-- "test" BYVALmode-EXPRmode-POLYmode (site: value result in Test)
| | | | | \-> String("test")
| | | | solving for (I: ?I, O: ?O)
| | | | solving for (O: ?O)
| | | | solving for (O: ?O)
| | | | solving for (O: ?O)
| | | | |-- new Insert("test") BYVALmode-EXPRmode-POLYmode (site solving: type O: value result in Test)
| | | | | |-- new Insert BYVALmode-EXPRmode-FUNmode-POLYmode (silent solving: type O: value result in Test)
| | | | | | |-- new Insert EXPRmode-POLYmode-QUALmode (silent solving: type O: value result in Test)
| | | | | | | |-- Insert[I,O] FUNmode-TYPEmode (silent solving: type O: value result in Test)
| | | | | | | | \-> Insert
| | | | | | | \-> Insert[I,O]
| | | | | | \-> (arg: I)(implicit evidence$1: Ord[O])Insert[I,O]
| | | | | |-- "test" BYVALmode-EXPRmode-POLYmode (site: value result in Test)
| | | | | | \-> String("test")
| | | | | solving for (I: ?I, O: ?O)
| | | | | solving for (O: ?O)
| | | | | solving for (O: ?O)
| | | | | solving for (O: ?O)
sandbox/test.scala:10: error: ambiguous implicit values:
both method A in object Ord of type => Ord[String]
and method B in object Ord of type => Ord[Int]
match expected type Ord[O]
val result: Int = execute(new Insert("test"))
^
| | | | | |-- (arg: I)(implicit evidence$1: Ord[O])Insert[I,O] BYVALmode-EXPRmode-POLYmode (site solving: type O: value result in Test)
| | | | | | solving for (O: ?O)
| | | | | | \-> <error>
| | | | | [adapt] (arg: I)(implicit evidence$1: Ord[O])Insert[I,O] adapted to (arg: I)(implicit evidence$1: Ord[O])Insert[I,O]
| | | | | \-> <error>
| | | | [adapt] (arg: I)(implicit evidence$1: Ord[O])Insert[I,O] adapted to (arg: I)(implicit evidence$1: Ord[O])Insert[I,O] based on pt Insert[?,?]
| | | | \-> <error>
| | | solving for (O: ?O)
| | | \-> <error>
| | \-> [val result ] Int
| |-- def result BYVALmode-EXPRmode (site: object Test)
| | |-- Int : pt=Int EXPRmode (site: value result in Test)
| | | |-- Test.type EXPRmode-POLYmode-QUALmode (site: value result in Test)
| | | | \-> Test.type
| | | \-> Int
| | \-> [def result] => Int
| \-> [object Test] Test.type
[[syntax trees at end of typer]] // test.scala
package <empty> {
abstract trait Ord[A] extends scala.AnyRef;
object Ord extends scala.AnyRef {
def <init>(): Ord.type = {
Ord.super.<init>();
()
};
implicit def A: Ord[String] = scala.this.Predef.???;
implicit def B: Ord[Int] = scala.this.Predef.???
};
class Insert[I, O] extends scala.AnyRef {
<paramaccessor> private[this] val arg: I = _;
implicit <synthetic> <paramaccessor> private[this] val evidence$1: Ord[O] = _;
def <init>(arg: I)(implicit evidence$1: Ord[O]): Insert[I,O] = {
Insert.super.<init>();
()
}
};
object Test extends scala.AnyRef {
def <init>(): Test.type = {
Test.super.<init>();
()
};
def execute[I, O](req: Insert[I,O]): O = null.asInstanceOf[O];
private[this] val result: Int = Test.this.execute[I, O](new Insert("test"));
<stable> <accessor> def result: Int = Test.this.result
}
}
one error found