Skip to content

Commit ba6a973

Browse files
Merge pull request #6569 from dotty-staging/fix-tasty-reflect-class-method
Fix #6543: propagate previous fix
2 parents e81fa4a + 6b74145 commit ba6a973

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -1549,18 +1549,16 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
15491549
}.toList
15501550
}
15511551

1552+
private def appliedTypeRef(sym: Symbol): Type = sym.typeRef.appliedTo(sym.typeParams.map(_.typeRef))
1553+
15521554
def ClassDefSymbol_method(self: Symbol)(name: String)(implicit ctx: Context): List[DefDefSymbol] = {
1553-
self.typeRef.allMembers.iterator.map(_.symbol).collect {
1555+
appliedTypeRef(self).allMembers.iterator.map(_.symbol).collect {
15541556
case sym if isMethod(sym) && sym.name.toString == name => sym.asTerm
15551557
}.toList
15561558
}
15571559

15581560
def ClassDefSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] = {
1559-
val classTpe = self.typeRef.appliedTo(self.typeParams.map { param =>
1560-
if (param.variance == -1) param.info.hiBound
1561-
else param.info.loBound
1562-
})
1563-
classTpe.allMembers.iterator.map(_.symbol).collect {
1561+
appliedTypeRef(self).allMembers.iterator.map(_.symbol).collect {
15641562
case sym if isMethod(sym) => sym.asTerm
15651563
}.toList
15661564
}

tests/run-macros/i6518/Macro_1.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ object Macros {
88

99
private def testImpl(implicit reflect: Reflection): Expr[String] = {
1010
import reflect._
11-
typeOf[Function1[_, _]].classSymbol.get.methods.map(_.name).sorted.mkString("\n")
11+
val classSym = typeOf[Function1[_, _]].classSymbol.get
12+
classSym.classMethod("apply")
13+
classSym.classMethods
14+
classSym.method("apply")
15+
classSym.methods.map(_.name).sorted.mkString("\n")
1216
}
1317

1418
}

0 commit comments

Comments
 (0)