Skip to content

Commit 60c92b5

Browse files
committed
first commit, demonstrating the following bug
type bound are displayed as: Refined.Node {type T = <: Int} where it should be: Refined.Node {type T <: Int} fix the bug, TypeBound now has its own case Formatting subroutine
1 parent ffd86c6 commit 60c92b5

8 files changed

Lines changed: 41 additions & 5 deletions

File tree

core/src/main/scala-2.13.7+/latest/splain/SplainFormattersExtension.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ trait SplainFormattersExtension extends SplainFormatters {
5858
}
5959

6060
def formatDecl: Symbol => Formatted = {
61+
case sym if sym.hasRawInfo && sym.rawInfo.isInstanceOf[TypeBounds] =>
62+
val name = sym.simpleName.toString
63+
val bounds = formatType(sym.rawInfo, top = true)
64+
val boundsStr = self.showFormatted(bounds)
65+
Simple(s"type $name$boundsStr")
6166
case DeclSymbol(n, t) =>
6267
Decl(n, t)
6368
case sym =>

core/src/test/resources/splain/builtin/BasicSpec/__direct/check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ newSource1.scala:21: error: type mismatch;
192192
}
193193
f(x)
194194
^
195+
newSource1.scala:9: error: implicit error;
196+
!I e: Refined.Node {type T <: Int}
197+
implicitly[NodeLt[Int]]
198+
^
199+
newSource1.scala:11: error: type mismatch;
200+
Int(1)┃Refined.Node {type T <: Int}
201+
val k: NodeLt[Int] = 1
202+
^
195203
newSource1.scala:10: error: implicit error;
196204
!I e: Refined.Node{type T = _$2} forSome { type _$2 <: Int }
197205
implicitly[NodeLt[Int]]

core/src/test/scala/splain/builtin/BasicSpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class BasicSpec extends SpecBase.Direct with BasicFixture {
4444

4545
check(refined2, numberOfErrors = 2)
4646

47+
check(refined3, numberOfErrors = 2)
48+
4749
check(disambiguateQualified)
4850

4951
check(bynameParam)

core/src/testFixtures/scala/splain/builtin/BasicFixture.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ object Refined
243243
type T
244244
}
245245
246+
type NodeLt[T0] = Node {type T <: T0}
247+
248+
implicitly[NodeLt[Int]]
249+
250+
val k: NodeLt[Int] = 1
251+
}
252+
"""
253+
254+
final val refined3 =
255+
"""
256+
object Refined
257+
{
258+
trait Node {
259+
type T
260+
}
261+
246262
type NodeAux[T0] = Node { type T = T0 }
247263
type NodeLt[T0] = NodeAux[_ <: T0]
248264

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

gradlew

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/acceptance/src/test/resources/splain/builtin/BasicSpec/__direct/check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ newSource1.scala:11: error: type mismatch;
231231
}
232232
f(x)
233233
^
234+
newSource1.scala:9: error: implicit error;
235+
!I e: splain.acceptance.builtin.StaticBasicSpec.Refined.Node {type T <: Int}
236+
implicitly[NodeLt[Int]]
237+
^
234238
newSource1.scala:10: error: implicit error;
235239
!I e: splain.acceptance.builtin.StaticBasicSpec.Refined.Node{type T = _$1} forSome { type _$1 <: Int }
236240
implicitly[NodeLt[Int]]

testing/acceptance/src/test/scala/splain/acceptance/builtin/StaticBasicSpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class StaticBasicSpec extends Acceptance.SpecBase {
5454

5555
check(refined2, numberOfErrors = 2)
5656

57+
check(refined3, numberOfErrors = 2)
58+
5759
check(disambiguateQualified)
5860

5961
check(bynameParam)

0 commit comments

Comments
 (0)