Skip to content

Commit a2f0ef5

Browse files
committed
Fix issue that prevented instantiating some tvars before implicit search
1 parent 6362c64 commit a2f0ef5

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ object Inferencing {
141141
if (toTest.isEmpty) acc
142142
else tree match {
143143
case Apply(fn, _) =>
144-
fn.tpe match {
144+
fn.tpe.widen match {
145145
case mtp: MethodType =>
146146
val (occ, nocc) = toTest.partition(tvar => mtp.paramTypes.exists(tvar.occursIn))
147147
occurring(fn, nocc, occ ::: acc)

tests/pos/tparam_inf.scala

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
1+
class HasFoo[T] {
2+
val x: Foo[T] = ???
3+
}
4+
class Foo[T] {
5+
def get(x: T): T = x
6+
def get2(x: T): Nothing = ???
7+
8+
def foo1(x: T)(implicit ev: T): Nothing = ???
9+
def foo2(x: T)(implicit ev: T): T = ???
10+
def foo3[Dummy](x: T)(implicit ev: T): Nothing = ???
11+
def foo4[Dummy](x: T)(implicit ev: T): T = ???
12+
}
13+
114
object Test {
15+
216
def foo1[T](x: T)(implicit ev: T): Nothing = ???
317
def foo2[T](x: T)(implicit ev: T): T = ???
418

5-
def test: Unit = {
19+
def test1: Unit = {
620
implicit val ii: Int = 42
721

822
foo1(10)
923
foo2(10)
1024
}
11-
}
1225

26+
def hf[T]: HasFoo[T] = ???
27+
def test2: Unit = {
28+
implicit val ii: Int = 42
29+
30+
hf.x.get(10)
31+
hf.x.get2(10)
32+
33+
hf.x.foo1(10)
34+
hf.x.foo2(10)
35+
hf.x.foo3(10)
36+
hf.x.foo4(10)
37+
}
38+
}

0 commit comments

Comments
 (0)