Closed
Description
class Foo[-T]
object Test {
def foo[A](x: Foo[A]): Int = 0
foo(new Foo[Int])
}
scalac
infers A
to be Int
:
fsc -Xprint:typer try/brokeninf.scala
[[syntax trees at end of typer]] // brokeninf.scala
package <empty> {
class Foo[-T] extends scala.AnyRef {
def <init>(): Foo[T] = {
Foo.super.<init>();
()
}
};
object Test extends scala.AnyRef {
def <init>(): Test.type = {
Test.super.<init>();
()
};
def foo[A](x: Foo[A]): Int = 0;
Test.this.foo[Int](new Foo[Int]())
}
}
But dotty infers A
to be Nothing
:
./bin/dotc -Xprint:frontend try/brokeninf.scala
result of try/brokeninf.scala after frontend:
package <empty> {
class Foo[T]() extends Object() {
type Foo$$T
private[this] type T =- Foo$$T
}
final lazy module val Test: Test$ = new Test$()
final module class Test$() extends Object() { this: Test.type =>
def foo[A](x: Foo[A]): Int = 0
Test.foo[Nothing](new Foo[Int][Int]())
}
}
This is probably not what we want, especially for function types.
Metadata
Metadata
Assignees
Labels
No labels