From aa99ba684e252b3e499aa8fe67d09d40ec05d8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Ol=C4=99dzki?= Date: Sat, 3 Oct 2020 13:32:21 +0200 Subject: [PATCH] UT for #378 --- .../inspections/AsInstanceOfTest.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/scala/com/sksamuel/scapegoat/inspections/AsInstanceOfTest.scala b/src/test/scala/com/sksamuel/scapegoat/inspections/AsInstanceOfTest.scala index a4602169..6307d545 100644 --- a/src/test/scala/com/sksamuel/scapegoat/inspections/AsInstanceOfTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/inspections/AsInstanceOfTest.scala @@ -70,5 +70,22 @@ class AsInstanceOfTest extends InspectionTest { compileCodeSnippet(code) compiler.scapegoat.feedback.warnings.size shouldBe 0 } + "should not warn on GADT pattern matching (#378)" in { + val code = + """ + |sealed trait MyGADT[T] + |final case class VariantInt(value: Int) extends MyGADT[Int] + |final case class VariantString(value: String) extends MyGADT[String] + | + |def doStuff[T](gadt: MyGADT[T]): T = { + | gadt match { + | case VariantInt(value) => value + | case VariantString(value) => value + | } + |} + |""".stripMargin + compileCodeSnippet(code) + compiler.scapegoat.feedback.warnings.size shouldBe 0 + } } }