Repository: scalameta/scalameta (scala)

Issue:
Init Seq vs List ambiguous overload
Whereas pattern matching `scala.meta.Init` works with last parameter `argss` as `Nil` - i.e., a `List[List[Term]]` -, when creating `Init`, there is the primary constructor that uses `argClauses` which is a `Seq[Term.ArgClause]`, and a secondary constructor, so gives this error:

    Ambiguous overload. The overloaded alternatives of method apply in object Init with types
     (tpe: scala.meta.Type, name: scala.meta.Name, argss: List[List[scala.meta.Term]]): scala.meta.Init
     (tpe: scala.meta.Type, name: scala.meta.Name, argClauses: Seq[scala.meta.Term.ArgClause]): scala.meta.Init
    both match arguments (scala.meta.Type.Select, scala.meta.Name.Anonymous, (Nil scala.collection.immutable.Nil.type))

Working textually at the metaprogramming level, I have to use `sed` to replace `Nil` with `Seq()` before pasting the constructor, e.g., `Init(Type.Name(...), Name.Anonymous(), Seq())`. But trying to find the occurrence of `Nil` is a no go.

It is the only exception of this case afik. (EDIT: `Ctor.Primary(Nil, Name.Anonymous(), Nil)` is also the case)

Pointing only at `scala.meta.Trees.scala#1084`, a quick fix is to add a ("another"?) _secondary_ constructor:

    def this(tpe: Type, name: Name, _nil: Nil.type) = this(tpe, name, Seq())

but isn't it cumbersome?! ;)

Pull request description:
Fixes #3725.

Patch:
diff --git a/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeStructure.scala b/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeStructure.scala
index f422dc15b2..f77888b210 100644
--- a/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeStructure.scala
+++ b/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeStructure.scala
@@ -37,6 +37,8 @@ object TreeStructure {
           x match {
             case _: Quasi => default
             case x: Lit.String => s(DoubleQuotes.orTriple(x.value))
+            case x: Lit.Char => s(s"'${x.value}'")
+            case x: Lit.Symbol => s(s"""Symbol("${x.value.name}")""")
             case _: Lit.Unit | _: Lit.Null => s()
             case x: Lit.Double => s(asFloat(x.format, 'd'))
             case x: Lit.Float => s(asFloat(x.format, 'f'))


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/CommonTrees.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/CommonTrees.scala
index e8a5c027af..18c99b30f9 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/CommonTrees.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/CommonTrees.scala
@@ -112,6 +112,10 @@ trait CommonTrees {
   final def flt(v: String) = Lit.Float(v)
   final def lit(v: Float) = Lit.Float(v)
   final def str(v: String) = Lit.String(v)
+  final def lit(v: String) = str(v)
+  final def lit(v: Char) = Lit.Char(v)
+  final def sym(v: String) = lit(Symbol(v))
+  final def lit(v: Symbol) = Lit.Symbol(v)
   final def init(name: String, args: List[Term.ArgClause] = Nil): Init =
     Init(pname(name), anon, args)
   final def blk(stats: List[Stat]): Term.Block = Term.Block(stats)
diff --git a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/TreeStructureSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/TreeStructureSuite.scala
index a7aede4874..7f82b388c8 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/TreeStructureSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/TreeStructureSuite.scala
@@ -32,6 +32,8 @@ class TreeStructureSuite extends ParseSuite {
   assertStructure(bool(false))("Lit.Boolean(false)")
   assertStructure(bool(true))("Lit.Boolean(true)")
   assertStructure(str("lit.str"))("""Lit.String("lit.str")""")
+  assertStructure(lit('a'))("Lit.Char('a')")
+  assertStructure(sym("a"))("""Lit.Symbol(Symbol("a"))""")
 
   assertStructure(Case(Pat.Wildcard(), None, Term.Function(List(tparam("")), bool(false))))(
     """|