Skip to content

Commit

Permalink
fix: workaround for printing Tuple1
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Oct 23, 2023
1 parent b638964 commit 728623b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ class MetalsGlobal(
val result = tpe match {
case TypeRef(pre, sym, args) =>
def shortSymbol = {
// workaround for Tuple1 (which is incorrectly printed by Scala 2 compiler)
def isTuple1 = sym == definitions.TupleClass(1)
/* If it's an alias type we want to prevent dealiasing it
AnyRef should stay to be dropped if neded later on since it's
not an important class.
*/
if (sym.isAliasType && sym != definitions.AnyRefClass)
if ((sym.isAliasType && sym != definitions.AnyRefClass) || isTuple1)
backtickify(sym.newErrorSymbol(sym.name).updateInfo(sym.info))
else backtickify(sym)
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cross/src/test/scala/tests/pc/InsertInferredTypeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,18 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite {
|""".stripMargin,
)

checkEdit(
"tuple1",
"""|object A {
| val <<v>> = List.empty[Tuple1[Int]]
|}
|""".stripMargin,
"""|object A {
| val v: List[Tuple1[Int]] = List.empty[Tuple1[Int]]
|}
|""".stripMargin,
)

def checkEdit(
name: TestOptions,
original: String,
Expand Down

0 comments on commit 728623b

Please sign in to comment.