Skip to content

Commit dbd7777

Browse files
committed
Fix type of modue objects
1 parent af178fd commit dbd7777

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
615615
def printTypeTree(tree: TypeTree): Buffer = tree match {
616616
case TypeTree.Synthetic() =>
617617
printType(tree.tpe)
618+
tree.tpe match {
619+
case tpe @ Type.TypeRef(name, _) if name.endsWith("$") => this += ".type"
620+
case tpe => this
621+
}
618622

619623
case TypeTree.TypeIdent(name) =>
620624
printType(tree.tpe)
@@ -713,9 +717,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
713717
case Type.TypeRef(name, prefix) =>
714718
prefix match {
715719
case NoPrefix() | Type.ThisType(Types.EmptyPackage()) =>
716-
case prefix@Type() =>
717-
printType(prefix)
718-
this += "."
720+
case prefix@Type() => printType(prefix) += "."
719721
}
720722
this += name.stripSuffix("$")
721723

tests/pos/i2104.decompiled

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
class Cons[H, T]() extends java.lang.Object
33
object Cons {
44
def apply[H, T](h: H, t: T): Cons[H, T] = scala.Predef.???
5-
def unapply[H, T](t: Cons[H, T]): scala.Option[<empty>.Pair[H, T]] = scala.Predef.???
6-
}/** Decompiled from out/posTestFromTasty/pos/i2104/Pair.class */
5+
def unapply[H, T](t: Cons[H, T]): scala.Option[Pair[H, T]] = scala.Predef.???
6+
}
7+
/** Decompiled from out/posTestFromTasty/pos/i2104/Pair.class */
78
case class Pair[A, B](_1: A, _2: B) {
8-
def copy[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any](_1: A, _2: B): Pair[A, B] = new Pair[A, B](_1, _2)
9-
def copy$default$1[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any]: Pair.A = (Pair._1: Pair._1)
10-
def copy$default$2[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any]: Pair.B = (Pair._2: Pair._2)
119
override def hashCode(): scala.Int = {
1210
var acc: scala.Int = 2479866
13-
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair._1))
14-
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair._2))
11+
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair.this._1))
12+
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair.this._2))
1513
scala.runtime.Statics.finalizeHash(acc, 2)
1614
}
1715
override def equals(x$0: scala.Any): scala.Boolean = this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match {
18-
case x$0: Pair[Pair.A, Pair.B] =>
16+
case x$0: Pair[Pair.this.A, Pair.this.B] =>
1917
this._1.==(x$0._1).&&(this._2.==(x$0._2))
2018
case _ =>
2119
false
2220
})
2321
override def toString(): java.lang.String = scala.runtime.ScalaRunTime._toString(this)
24-
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[Pair[Pair.A, Pair.B]]
22+
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[Pair[Pair.this.A, Pair.this.B]]
2523
override def productArity: scala.Int = 2
2624
override def productPrefix: java.lang.String = "Pair"
2725
override def productElement(n: scala.Int): scala.Any = n match {
@@ -33,18 +31,14 @@ case class Pair[A, B](_1: A, _2: B) {
3331
throw new java.lang.IndexOutOfBoundsException(n.toString())
3432
}
3533
}
36-
object Pair extends scala.AnyRef {
37-
def apply[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any](_1: A, _2: B): Pair[A, B] = new Pair[A, B](_1, _2)
38-
def unapply[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any](x$1: Pair[A, B]): Pair[A, B] = x$1
39-
}/** Decompiled from out/posTestFromTasty/pos/i2104/Test.class */
34+
object Pair extends scala.AnyRef
35+
/** Decompiled from out/posTestFromTasty/pos/i2104/Test.class */
4036
object Test {
4137
def main(args: scala.Array[scala.Predef.String]): scala.Unit = {
42-
<empty>.Cons.apply[scala.Option[scala.Int], scala.None](scala.Option.apply[scala.Int](1), scala.None) match {
43-
case <empty>.Cons.unapply[scala.Option[scala.Int], scala.None](, scala.None) =>
44-
{
45-
(i: scala.Int)
46-
dotty.DottyPredef.assert(i.==(1))
47-
}
38+
Cons.apply[scala.Option[scala.Int], scala.None.type](scala.Option.apply[scala.Int](1), scala.None) match {
39+
case Cons(scala.Some(i), scala.None) =>
40+
(i: scala.Int)
41+
dotty.DottyPredef.assert(i.==(1))
4842
}
4943
}
5044
}

0 commit comments

Comments
 (0)