Skip to content

Fixes #6626. Pass sym.name to sanitizeName instead of sym.name.asSimpleName #7290

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 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import core.Annotations.Annotation
import core.Contexts.Context
import core.Definitions
import core.Flags._
import core.Names.Name
import core.Names.{DerivedName, Name, SimpleName, TypeName}
import core.Symbols._
import core.TypeApplications.TypeParamInfo
import core.TypeErasure.erasure
Expand All @@ -17,6 +17,8 @@ import SymUtils._
import TypeUtils._
import java.lang.StringBuilder

import scala.annotation.tailrec

/** Helper object to generate generic java signatures, as defined in
* the Java Virtual Machine Specification, §4.3.4
*/
Expand Down Expand Up @@ -161,7 +163,7 @@ object GenericSignatures {

// TODO revisit this. Does it align with javac for code that can be expressed in both languages?
val delimiter = if (builder.charAt(builder.length() - 1) == '>') '.' else '$'
builder.append(delimiter).append(sanitizeName(sym.name.asSimpleName))
builder.append(delimiter).append(sanitizeName(sym.name))
}
else fullNameInSig(sym)
}
Expand Down
1 change: 1 addition & 0 deletions tests/generic-java-signatures/derivedNames.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test$Foo$A<Test$Foo<T1>$B$>
15 changes: 15 additions & 0 deletions tests/generic-java-signatures/derivedNames.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
object Test {
def main(args: Array[String]): Unit = {
val objectB = classOf[Foo[Any]].getClasses
val returnType = objectB(1).getDeclaredMethod("m").getGenericReturnType
println(returnType)
}
class Foo[T1] {
class A[T2]

object B {
def m: A[B.type] = ???
}
}
}