Skip to content

Commit 088902c

Browse files
committed
Do not miss implicits in type parameters of parents
This did not work before because we incorrectly looked for their value in the prefix of the type instead of the type itself.
1 parent 818bf0b commit 088902c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ trait ImplicitRunInfo { self: RunInfo =>
323323
def addParentScope(parent: TypeRef): Unit = {
324324
iscopeRefs(parent) foreach addRef
325325
for (param <- parent.typeParams)
326-
comps ++= iscopeRefs(pre.member(param.name).info)
326+
comps ++= iscopeRefs(tp.member(param.name).info)
327327
}
328328
val companion = cls.companionModule
329329
if (companion.exists) addRef(companion.valRef)

tests/pos/implicit_tparam.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Foo[T]
2+
class Bar extends Foo[A]
3+
4+
class A
5+
object A {
6+
implicit val bar: Bar = new Bar
7+
}
8+
9+
object Test {
10+
def getBar(implicit bar: Bar) = bar
11+
getBar
12+
}

0 commit comments

Comments
 (0)