Skip to content

Commit 301943c

Browse files
authored
Merge pull request #10936 from changvvb/enable-local-class-signature
Generate signature for local class
2 parents b1dafb7 + 3463a07 commit 301943c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ object GenericSignatures {
3333
* @return The signature if it could be generated, `None` otherwise.
3434
*/
3535
def javaSig(sym0: Symbol, info: Type)(using Context): Option[String] =
36-
// Avoid generating a signature for local symbols.
37-
if (sym0.isLocal) None
36+
// Avoid generating a signature for non-class local symbols.
37+
if (sym0.isLocal && !sym0.isClass) None
3838
else atPhase(erasurePhase)(javaSig0(sym0, info))
3939

4040
@noinline
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Foo<java.lang.String>
2+
Foo<java.lang.String>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Foo[T]
2+
object Test {
3+
class Inner extends Foo[String]
4+
5+
def main(args: Array[String]): Unit = {
6+
class Local extends Foo[String]
7+
8+
println((new Inner).getClass.getGenericSuperclass) // Foo<java.lang.String>
9+
10+
println((new Local).getClass.getGenericSuperclass) // Foo<java.lang.String>
11+
}
12+
}

0 commit comments

Comments
 (0)