Skip to content

Commit b86b76f

Browse files
committed
Do not print lazy vals from inner objects
1 parent 3926092 commit b86b76f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
126126
case _ => false
127127
})
128128
}
129-
!flags.isParam && !flags.isParamAccessor && !isCaseClassUnOverridableMethod
129+
def isInnerModuleObject = d.flags.isLazy && d.flags.isObject
130+
!flags.isParam && !flags.isParamAccessor && !isCaseClassUnOverridableMethod && !isInnerModuleObject
130131
}
131132
val stats1 = stats.collect {
132133
case stat@Definition() if keepDefinition(stat) => stat

tests/pos/simpleSingleton.decompiled

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ class Foo() {
33
def foo(x: scala.Int): scala.Unit = {
44
val a: x.type = x
55
val b: Foo.type = Foo
6+
val c: Foo.Bar.type = Foo.Bar
67
()
78
}
89
}
9-
object Foo
10+
object Foo {
11+
object Bar
12+
}

tests/pos/simpleSingleton.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ class Foo {
22
def foo(x: Int) = {
33
val a: x.type = x
44
val b: Foo.type = Foo
5+
val c: Foo.Bar.type = Foo.Bar
56
}
67
}
78

8-
object Foo
9+
object Foo {
10+
object Bar
11+
}

0 commit comments

Comments
 (0)