diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala index 9d3f80e4dcb1..63181c3aa638 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala @@ -1556,7 +1556,11 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. } def ClassDefSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] = { - self.typeRef.allMembers.iterator.map(_.symbol).collect { + val classTpe = self.typeRef.appliedTo(self.typeParams.map { param => + if (param.variance == -1) param.info.hiBound + else param.info.loBound + }) + classTpe.allMembers.iterator.map(_.symbol).collect { case sym if isMethod(sym) => sym.asTerm }.toList } diff --git a/tests/run-macros/i6518.check b/tests/run-macros/i6518.check new file mode 100644 index 000000000000..388ef88a5170 --- /dev/null +++ b/tests/run-macros/i6518.check @@ -0,0 +1,24 @@ +!= +## +$asInstanceOf$ +$isInstanceOf$ +== +andThen +apply +asInstanceOf +clone +compose +eq +equals +finalize +getClass +hashCode +isInstanceOf +ne +notify +notifyAll +synchronized +toString +wait +wait +wait diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala new file mode 100644 index 000000000000..532e6edc7bcb --- /dev/null +++ b/tests/run-macros/i6518/Macro_1.scala @@ -0,0 +1,14 @@ +import scala.quoted._ +import scala.quoted.autolift._ +import scala.tasty._ + +object Macros { + + inline def test(): String = ${ testImpl } + + private def testImpl(implicit reflect: Reflection): Expr[String] = { + import reflect._ + typeOf[Function1[_, _]].classSymbol.get.methods.map(_.name).sorted.mkString("\n") + } + +} diff --git a/tests/run-macros/i6518/Test_2.scala b/tests/run-macros/i6518/Test_2.scala new file mode 100644 index 000000000000..f0a2a8a00ab8 --- /dev/null +++ b/tests/run-macros/i6518/Test_2.scala @@ -0,0 +1,8 @@ + +object Test { + + def main(args: Array[String]): Unit = { + println(Macros.test()) + } + +}