Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanelamyaghri committed Jul 12, 2023
2 parents 948ee8c + 58d4e9f commit 0cfc257
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.7"
version = "3.7.8"
project.git = true
align.preset = none
align.stripMargin = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ abstract class ScalaUnpickler(scalaVersion: ScalaVersion, testMode: Boolean) ext
// TODO in Scala 3 we should be able to find the symbol of a local class using TASTy Query
else if (isLocalClass(method.declaringType)) Some(formatJava(method))
else if (scalaVersion.isScala2 && isNestedClass(method.declaringType)) Some(formatJava(method))
else if (isDefaultValue(method)) Some(formatJava(method))
else
try formatScala(method)
catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,38 @@ class ScalaStackTraceTests extends DebugTestSuite {

}

test("should show the correct stack trace when using default values") {
val source =
"""|package example
|def m1(y : Int)(z : Int , x: Int = m2(y)): Int = {
| x * 2
|}
|
|def m2(t : Int ) : Int = {
| t*2
|}
|
|object Main {
| def main(args: Array[String]): Unit = {
| println(m1(2)(3))
| }
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)

check(
Breakpoint(
7,
List(
"example.m2(t: Int): Int",
"example.m1.<default 3>(y: Int): Int",
"Main.main(args: Array[String]): Unit"
)
)
)

}

test("correct stacktrace with a lazy val") {
val source =
"""|package example
Expand Down Expand Up @@ -216,7 +248,6 @@ class ScalaStackTraceTests extends DebugTestSuite {
)
)
)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ class Scala3Unpickler(
case owner: ClassSymbol if isPackageObject(owner.name) => formatSymbol(owner.owner)
case owner: TermOrTypeSymbol => formatSymbol(owner)
case owner: PackageSymbol => ""
if prefix.isEmpty then sym.name.toString else s"$prefix.${sym.name}"
val symName = sym.name match
case DefaultGetterName(termName, num) => s"${termName.toString()}.<default ${num + 1}>"
case _ => sym.name.toString()

if prefix.isEmpty then symName else s"$prefix.${symName}"

private def isPackageObject(name: Name): Boolean =
name.toString == "package" || name.toString.endsWith("$package")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,14 @@ abstract class Scala3UnpicklerTests(val scalaVersion: ScalaVersion) extends FunS
val debuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
val unpickler = getUnpickler(debuggee)

unpickler.assertFormat("example.A", "java.lang.String m$default$1()", "A.m$default$1: String")
unpickler.assertFormat("example.A", "int m$default$2()", "A.m$default$2: Int")
unpickler.assertFormat("example.A$", "java.lang.String $lessinit$greater$default$1()", "A.<init>$default$1: String")
unpickler.assertFormat("example.A$", "int $lessinit$greater$default$2()", "A.<init>$default$2: Int")
unpickler.assertFormat("example.A", "java.lang.String m$default$1()", "A.m.<default 1>: String")
unpickler.assertFormat("example.A", "int m$default$2()", "A.m.<default 2>: Int")
unpickler.assertFormat(
"example.A$",
"java.lang.String $lessinit$greater$default$1()",
"A.<init>.<default 1>: String"
)
unpickler.assertFormat("example.A$", "int $lessinit$greater$default$2()", "A.<init>.<default 2>: Int")
}

test("matches on return types") {
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object Dependencies {
val scalaParallelCollection = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0"
val sbtTestAgent = "org.scala-sbt" % "test-agent" % "1.9.1"
val scalaMeta = ("org.scalameta" %% "parsers" % "4.8.2").cross(CrossVersion.for3Use2_13)
val scalaMeta = ("org.scalameta" %% "parsers" % "4.8.3").cross(CrossVersion.for3Use2_13)

// test dependencies
val munit = "org.scalameta" %% "munit" % "1.0.0-M8"
Expand Down

0 comments on commit 0cfc257

Please sign in to comment.