Skip to content

Fix Java generic signatures for aliases #13574

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
Sep 21, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ object GenericSignatures {
private class NeedsSigCollector(using Context) extends TypeAccumulator[Boolean] {
override def apply(x: Boolean, tp: Type): Boolean =
if (!x)
tp match {
tp.dealias match {
case RefinedType(parent, refinedName, refinedInfo) =>
val sym = parent.typeSymbol
if (sym == defn.ArrayClass) foldOver(x, refinedInfo)
Expand All @@ -471,9 +471,7 @@ object GenericSignatures {
foldOver(tp.typeParams.nonEmpty, parents)
case AnnotatedType(tpe, _) =>
foldOver(x, tpe)
case proxy: TypeProxy =>
foldOver(x, proxy)
case _ =>
case tp =>
foldOver(x, tp)
}
else x
Expand Down
1 change: 1 addition & 0 deletions tests/generic-java-signatures/aliases.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scala.collection.immutable.List<java.lang.String>
10 changes: 10 additions & 0 deletions tests/generic-java-signatures/aliases.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Foo {
type A = List[String]
def foo(): A = Nil
}

object Test {
def main(args: Array[String]): Unit = {
println(classOf[Foo].getDeclaredMethod("foo").getGenericReturnType)
}
}