<commit_before>package org.jetbrains.plugins.scala
package codeInspection
package collections

/**
 * @author Nikolay.Tropin
 */
class RedundantConversionTest extends OperationsOnCollectionInspectionTest {

  override protected val classOfInspection: Class[_ <: OperationOnCollectionInspection] =
    classOf[RedundantCollectionConversionInspection]

  override protected val hint: String =
    ScalaInspectionBundle.message("redundant.collection.conversion")

  def test_1(): Unit = {
    doTest(s"List(1, 2).${START}toList$END",
      "List(1, 2).toList",
      "List(1, 2)")
  }

  def test_2(): Unit = {
    doTest(s"Seq(1, 2).${START}to[Seq]$END",
      "Seq(1, 2).to[Seq]",
      "Seq(1, 2)")
  }

  def test_2_with_implicit_generic(): Unit = {
    doTest(s"val x: List[Int] = List(1, 2).${START}to$END",
      "val x: List[Int] = List(1, 2).to",
      "val x: List[Int] = List(1, 2)")
  }

  def test_3(): Unit = {
    doTest(s"Map(1 -> true).${START}toMap[Int, Boolean]$END",
      "Map(1 -> true).toMap[Int, Boolean]",
      "Map(1 -> true)")
  }

  def test_4(): Unit = {
    doTest(
      s"""
         |def list() = List(1, 2)
         |list().${START}toList$END
       """.stripMargin,
      """
         |def list() = List(1, 2)
         |list().toList
       """.stripMargin,
      """
        |def list() = List(1, 2)
        |list()
      """.stripMargin
    )
  }

  def test_5(): Unit = {
    doTest(
      s"""Seq(1) match {
        |  case seq => seq.${START}toSeq$END
        |}""".stripMargin,
      s"""Seq(1) match {
          |  case seq => seq.toSeq
          |}""".stripMargin,
      s"""Seq(1) match {
          |  case seq => seq
          |}""".stripMargin

    )
  }

  // SCL-18210
  def test_toUpperCase_is_not_redundant(): Unit = checkTextHasNoErrors(
    """
      |val x = "test".toUpperCase
      |""".stripMargin
  )

  // SCL-18210
  def test_toLowerCase_is_not_redundant(): Unit = checkTextHasNoErrors(
    """
      |val x = "test".toLowerCase
      |""".stripMargin
  )
}<commit_msg>Fixed RedundantConversionTest for Scala 2.13<commit_after>package org.jetbrains.plugins.scala
package codeInspection
package collections

abstract class RedundantConversionTestBase extends OperationsOnCollectionInspectionTest {

  override protected val classOfInspection: Class[_ <: OperationOnCollectionInspection] =
    classOf[RedundantCollectionConversionInspection]

  override protected val hint: String =
    ScalaInspectionBundle.message("redundant.collection.conversion")

  def test_1(): Unit = {
    doTest(s"List(1, 2).${START}toList$END",
      "List(1, 2).toList",
      "List(1, 2)")
  }

  def test_3(): Unit = {
    doTest(s"Map(1 -> true).${START}toMap[Int, Boolean]$END",
      "Map(1 -> true).toMap[Int, Boolean]",
      "Map(1 -> true)")
  }

  def test_4(): Unit = {
    doTest(
      s"""
         |def list() = List(1, 2)
         |list().${START}toList$END
       """.stripMargin,
      """
        |def list() = List(1, 2)
        |list().toList
       """.stripMargin,
      """
        |def list() = List(1, 2)
        |list()
      """.stripMargin
    )
  }

  def test_5(): Unit = {
    doTest(
      s"""Seq(1) match {
         |  case seq => seq.${START}toSeq$END
         |}""".stripMargin,
      s"""Seq(1) match {
         |  case seq => seq.toSeq
         |}""".stripMargin,
      s"""Seq(1) match {
         |  case seq => seq
         |}""".stripMargin

    )
  }

  // SCL-18210
  def test_toUpperCase_is_not_redundant(): Unit = checkTextHasNoErrors(
    """
      |val x = "test".toUpperCase
      |""".stripMargin
  )

  // SCL-18210
  def test_toLowerCase_is_not_redundant(): Unit = checkTextHasNoErrors(
    """
      |val x = "test".toLowerCase
      |""".stripMargin
  )
}

class RedundantConversionTest extends RedundantConversionTestBase {

  override protected def supportedIn(version: ScalaVersion): Boolean = version <= LatestScalaVersions.Scala_2_12

  def test_to(): Unit = {
    doTest(s"Seq(1, 2).${START}to[Seq]$END",
      "Seq(1, 2).to[Seq]",
      "Seq(1, 2)")
  }

  def test_to_with_implicit_generic(): Unit = {
    doTest(s"val x: List[Int] = List(1, 2).${START}to$END",
      "val x: List[Int] = List(1, 2).to",
      "val x: List[Int] = List(1, 2)")
  }
}


class RedundantConversionTest_2_13 extends RedundantConversionTestBase {

  override protected def supportedIn(version: ScalaVersion): Boolean = version >= LatestScalaVersions.Scala_2_13

  // TODO: implement inspection for .to(Factory)
  /*
  def test_to(): Unit = {
    doTest(s"Seq(1, 2).${START}to(Seq)$END",
      "Seq(1, 2).to(Seq)",
      "Seq(1, 2)")
  }

  def test_to_with_implicit_generic(): Unit = {
    doTest(s"val x: List[Int] = List(1, 2).${START}to$END",
      "val x: List[Int] = List(1, 2).to",
      "val x: List[Int] = List(1, 2)")
  }
   */
}
{'fraction_non_alphanumeric': 0.16812136325852037, 'fraction_numerical': 0.02369077306733167, 'mean_word_length': 2.748442367601246, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5568960', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1740, 'n_words': 329}