Skip to content

Fix #6518: Add type parameters to class type before asking for members #6521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
24 changes: 24 additions & 0 deletions tests/run-macros/i6518.check
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions tests/run-macros/i6518/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -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")
}

}
8 changes: 8 additions & 0 deletions tests/run-macros/i6518/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

object Test {

def main(args: Array[String]): Unit = {
println(Macros.test())
}

}