File tree Expand file tree Collapse file tree 4 files changed +43
-2
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,9 @@ object GenericSignatures {
276276 else builder.append(defn.typeTag(sym.info))
277277 else if (sym.isDerivedValueClass) {
278278 if (unboxedVCs) {
279- val erasedUnderlying = fullErasure(tp)
280- jsig(erasedUnderlying, toplevel = toplevel, unboxedVCs = true )
279+ val underlying = ValueClasses
280+ .underlyingOfValueClass(sym.asClass, tp)
281+ jsig(underlying, toplevel = toplevel, unboxedVCs = true )
281282 } else classSig(sym, pre, args)
282283 }
283284 else if (defn.isSyntheticFunctionClass(sym)) {
Original file line number Diff line number Diff line change @@ -44,4 +44,9 @@ object ValueClasses {
4444 /** The unboxed type that underlies a derived value class */
4545 def underlyingOfValueClass (sym : ClassSymbol )(using Context ): Type =
4646 valueClassUnbox(sym).info.resultType
47+
48+ /** The unboxed type that underlies a derived value class as seen from as seen from tpe*/
49+ def underlyingOfValueClass (sym : ClassSymbol , tpe : Type )(using Context ): Type =
50+ valueClassUnbox(sym).info.resultType.asSeenFrom(tpe, sym)
51+
4752}
Original file line number Diff line number Diff line change 1+ public <A> scala.Option<Box<A>> Foo.bar1(scala.Option<Box<A>>)
2+ public <A> scala.Option<IBox> Foo.bar2(scala.Option<IBox>)
3+ public <A> scala.Option<SBox> Foo.bar3(scala.Option<SBox>)
4+ public <A> A Foo.foo1(A)
5+ public int Foo.foo2(int)
6+ public java.lang.String Foo.foo3(java.lang.String)
7+ public static <A> scala.Option<Box<A>> Foo.sbar1(scala.Option<Box<A>>)
8+ public static <A> scala.Option<IBox> Foo.sbar2(scala.Option<IBox>)
9+ public static <A> scala.Option<SBox> Foo.sbar3(scala.Option<SBox>)
10+ public static <A> A Foo.sfoo1(A)
11+ public static int Foo.sfoo2(int)
12+ public static java.lang.String Foo.sfoo3(java.lang.String)
Original file line number Diff line number Diff line change 1+ class Box [A ](value : A ) extends AnyVal
2+ class IBox (value : Int ) extends AnyVal
3+ class SBox (value : String ) extends AnyVal
4+
5+ class Foo :
6+ def foo1 [A ](a : A ): Box [A ] = Box (a)
7+ def foo2 (a : IBox ): IBox = a
8+ def foo3 (a : SBox ): SBox = a
9+ def bar1 [A ](opt : Option [Box [A ]]): Option [Box [A ]] = opt
10+ def bar2 [A ](opt : Option [IBox ]): Option [IBox ] = opt
11+ def bar3 [A ](opt : Option [SBox ]): Option [SBox ] = opt
12+
13+ object Foo :
14+ def sfoo1 [A ](a : A ): Box [A ] = Box (a)
15+ def sfoo2 (a : IBox ): IBox = a
16+ def sfoo3 (a : SBox ): SBox = a
17+ def sbar1 [A ](opt : Option [Box [A ]]): Option [Box [A ]] = opt
18+ def sbar2 [A ](opt : Option [IBox ]): Option [IBox ] = opt
19+ def sbar3 [A ](opt : Option [SBox ]): Option [SBox ] = opt
20+
21+ @ main def Test =
22+ for mtd <- classOf [Foo ].getDeclaredMethods.sortBy(_.getName) do
23+ println(mtd.toGenericString)
You can’t perform that action at this time.
0 commit comments