Skip to content

Commit

Permalink
Merge pull request #13574 from dotty-staging/gensig-alias
Browse files Browse the repository at this point in the history
Fix Java generic signatures for aliases
  • Loading branch information
smarter committed Sep 21, 2021
2 parents 87546c3 + 0f78102 commit fa40f4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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)
}
}

0 comments on commit fa40f4e

Please sign in to comment.