Repository: 7mind/izumi
Pull request #1084 (2020-05-27 18:55:55)

Request SourceFilePosition in distage-testkit-scalatest instead of full CodePosition
* optimize source position macro taking code from scalatest.Position

codecov-commenter: # [Codecov](https://codecov.io/gh/7mind/izumi/pull/1084?src=pr&el=h1) Report
> Merging [#1084](https://codecov.io/gh/7mind/izumi/pull/1084?src=pr&el=desc) into [develop](https://codecov.io/gh/7mind/izumi/commit/e9123a774ac2f50dbeecc2232d5996ea2555d00e&el=desc) will **increase** coverage by `0.10%`.
> The diff coverage is `74.35%`.


```diff
@@             Coverage Diff             @@
##           develop    #1084      +/-   ##
===========================================
+ Coverage    56.14%   56.24%   +0.10%     
===========================================
  Files          381      381              
  Lines         7030     6861     -169     
  Branches       359      359              
===========================================
- Hits          3947     3859      -88     
+ Misses        3083     3002      -81     
```


Patch:
diff --git a/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/CodePositionMaterializer.scala b/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/CodePositionMaterializer.scala
index 702c77f67..f23636011 100644
--- a/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/CodePositionMaterializer.scala
+++ b/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/CodePositionMaterializer.scala
@@ -1,5 +1,7 @@
 package izumi.fundamentals.platform.language
 
+import izumi.fundamentals.platform.language.SourceFilePositionMaterializer.SourcePositionMaterializerMacro
+
 import scala.annotation.tailrec
 import scala.collection.mutable
 import scala.language.experimental.macros
@@ -10,42 +12,26 @@ final case class CodePositionMaterializer(get: CodePosition) extends AnyVal
 object CodePositionMaterializer {
   @inline def apply()(implicit ev: CodePositionMaterializer, dummy: DummyImplicit): CodePositionMaterializer = ev
   @inline def codePosition(implicit ev: CodePositionMaterializer): CodePosition = ev.get
-  @inline def sourcePosition(implicit ev: CodePositionMaterializer): SourceFilePosition = ev.get.position
 
-  implicit def izCodePos: CodePositionMaterializer = macro CodePositionMaterializerMacro.getEnclosingPosition
+  implicit def materialize: CodePositionMaterializer = macro CodePositionMaterializerMacro.getEnclosingPosition
 
   object CodePositionMaterializerMacro {
+
     def getEnclosingPosition(c: blackbox.Context): c.Expr[CodePositionMaterializer] = {
       import c.universe._
-      val cp = getCodePosition(c)
+      val applicationPointId = getApplicationPointId(c)
+      val sourceFilePosition = c.Expr[SourceFilePosition](SourcePositionMaterializerMacro.getSourceFilePosition(c))
       reify {
-        CodePositionMaterializer(cp.splice)
-      }
-    }
-
-    def getCodePosition(c: blackbox.Context): c.Expr[CodePosition] = {
-      import c.universe._
-      getEnclosingPositionImpl(c) match {
-        case CodePosition(SourceFilePosition(file, line), applicationPointId) =>
-          reify {
-            CodePosition.apply(
-              SourceFilePosition(
-                c.Expr[String](Literal(Constant(file))).splice,
-                c.Expr[Int](Literal(Constant(line))).splice
-              ),
-              applicationPointId = c.Expr[String](Literal(Constant(applicationPointId))).splice
-            )
-          }
+        CodePositionMaterializer(CodePosition(sourceFilePosition.splice, applicationPointId.splice))
       }
     }
 
     def getApplicationPointId(c: blackbox.Context): c.Expr[String] = {
       import c.universe._
-      c.Expr[String](Literal(Constant(getEnclosingPositionImpl(c).applicationPointId)))
+      c.Expr[String](Literal(Constant(getApplicationPointIdImpl(c))))
     }
 
-    private def getEnclosingPositionImpl(c: blackbox.Context): CodePosition = {
-
+    def getApplicationPointIdImpl(c: blackbox.Context): String = {
       def goodSymbol(s: c.Symbol): Boolean = {
         val name = s.name.toString
         !name.startsWith("$") && !name.startsWith("<")
@@ -65,27 +51,21 @@ object CodePositionMaterializer {
       val st = mutable.ArrayBuffer[c.Symbol]()
       rec(c.internal.enclosingOwner, st)
 
-      val normalizedName = st
-        .tail
+      st.tail
         .map {
           case s if s.isPackage => s.name
           case s if goodSymbol(s) => s.name
-          case s => if (s.isClass) {
-            s.asClass.baseClasses.find(goodSymbol).map(_.name).getOrElse(s.pos.line)
-          } else {
-            s.pos.line
-          }
+          case s =>
+            if (s.isClass) {
+              s.asClass.baseClasses.find(goodSymbol).map(_.name).getOrElse(s.pos.line)
+            } else {
+              s.pos.line
+            }
         }
         .map(_.toString.trim)
         .mkString(".")
-
-      CodePosition(
-        SourceFilePosition(
-          line = c.enclosingPosition.line,
-          file = c.enclosingPosition.source.file.name
-        ),
-        applicationPointId = normalizedName
-      )
     }
+
   }
+
 }
diff --git a/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/SourceFilePositionMaterializer.scala b/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/SourceFilePositionMaterializer.scala
new file mode 100644
index 000000000..c063563d9
--- /dev/null
+++ b/fundamentals/fundamentals-language/src/main/scala/izumi/fundamentals/platform/language/SourceFilePositionMaterializer.scala
@@ -0,0 +1,62 @@
+package izumi.fundamentals.platform.language
+
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox
+
+final case class SourceFilePositionMaterializer(get: SourceFilePosition) extends AnyVal
+
+object SourceFilePositionMaterializer {
+  @inline def sourcePosition(implicit ev: SourceFilePositionMaterializer): SourceFilePosition = ev.get
+
+  implicit def materialize: SourceFilePositionMaterializer = macro SourcePositionMaterializerMacro.getSourceFilePositionMaterializer
+
+  object SourcePositionMaterializerMacro {
+
+    // scalactic.source.Position does all that manually and uses `setType`s to avoid retypechecking, oh well might as well...
+
+    def literal(c: blackbox.Context)(tpe: c.Type)(a: Any): c.universe.Literal = {
+      c.internal.setType(c.universe.Literal(c.universe.Constant(a)), tpe)
+    }
+
+    def getSourceFilePositionMaterializer(c: blackbox.Context): c.Tree = {
+      import c.universe._
+      import c.universe.internal._
+      import c.universe.internal.gen.{mkAttributedIdent, mkAttributedSelect}
+
+      val sourceFilePosition = getSourceFilePosition(c)
+
+      val matTpe = typeOf[SourceFilePositionMaterializer]
+      val matModule = matTpe.companion.typeSymbol.asClass.module
+
+      val sourceFilePositionMaterliazer = Apply(
+        mkAttributedSelect(
+          mkAttributedIdent(matModule),
+          matModule.typeSignature.decl(TermName("apply")),
+        ),
+        sourceFilePosition :: Nil,
+      )
+      setType(sourceFilePositionMaterliazer, matTpe)
+    }
+
+    def getSourceFilePosition(c: blackbox.Context): c.Tree = {
+      import c.universe._
+      import c.universe.internal._
+      import c.universe.internal.gen.{mkAttributedIdent, mkAttributedSelect}
+
+      val posTpe = typeOf[SourceFilePosition]
+      val posModule = posTpe.companion.typeSymbol.asClass.module
+
+      val sourceFilePosition = Apply(
+        mkAttributedSelect(
+          mkAttributedIdent(posModule),
+          posModule.typeSignature.decl(TermName("apply")),
+        ),
+        literal(c)(definitions.StringClass.toTypeConstructor)(c.enclosingPosition.source.file.name) ::
+        literal(c)(definitions.IntTpe)(c.enclosingPosition.line) :: Nil,
+      )
+      setType(sourceFilePosition, posTpe)
+    }
+
+  }
+
+}


Test patch:
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBIOBase.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBIOBase.scala
index 4caaec3dd..3f4a0988a 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBIOBase.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBIOBase.scala
@@ -4,12 +4,12 @@ import distage.{Tag, TagKK}
 import izumi.distage.model.providers.ProviderMagnet
 import izumi.functional.bio.BIOError
 import izumi.functional.bio.BIORunner.BIOBadBranch
-import izumi.fundamentals.platform.language.CodePosition
+import izumi.fundamentals.platform.language.SourceFilePosition
 
 trait DISyntaxBIOBase[F[+_, +_]] extends DISyntaxBase[F[Throwable, ?]] {
   implicit def tagBIO: TagKK[F]
 
-  protected final def takeBIO(function: ProviderMagnet[F[_, _]], pos: CodePosition): Unit = {
+  protected final def takeBIO(function: ProviderMagnet[F[_, _]], pos: SourceFilePosition): Unit = {
     val fAsThrowable: ProviderMagnet[F[Throwable, _]] = function
       .map2(ProviderMagnet.identity[BIOError[F]]) {
         (effect, F) =>
@@ -22,7 +22,7 @@ trait DISyntaxBIOBase[F[+_, +_]] extends DISyntaxBase[F[Throwable, ?]] {
     takeIO(fAsThrowable, pos)
   }
 
-  protected final def takeFunBIO[T: Tag](function: T => F[_, _], pos: CodePosition): Unit = {
+  protected final def takeFunBIO[T: Tag](function: T => F[_, _], pos: SourceFilePosition): Unit = {
     takeBIO(function, pos)
   }
 
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBase.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBase.scala
index 047a9945f..fb98ea082 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBase.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/DISyntaxBase.scala
@@ -3,14 +3,14 @@ package izumi.distage.testkit.services
 import distage.{Tag, TagK}
 import izumi.distage.model.effect.DIEffect
 import izumi.distage.model.providers.ProviderMagnet
-import izumi.fundamentals.platform.language.CodePosition
+import izumi.fundamentals.platform.language.SourceFilePosition
 
 trait DISyntaxBase[F[_]] {
   implicit def tagMonoIO: TagK[F]
 
-  protected def takeIO(function: ProviderMagnet[F[_]], pos: CodePosition): Unit
+  protected def takeIO(function: ProviderMagnet[F[_]], pos: SourceFilePosition): Unit
 
-  protected final def takeAny(function: ProviderMagnet[Any], pos: CodePosition): Unit = {
+  protected final def takeAny(function: ProviderMagnet[Any], pos: SourceFilePosition): Unit = {
     val f: ProviderMagnet[F[Any]] = function.flatAp {
       F: DIEffect[F] => (a: Any) =>
         F.pure(a)
@@ -19,11 +19,11 @@ trait DISyntaxBase[F[_]] {
     takeIO(f, pos)
   }
 
-  protected final def takeFunIO[T: Tag](function: T => F[_], pos: CodePosition): Unit = {
+  protected final def takeFunIO[T: Tag](function: T => F[_], pos: SourceFilePosition): Unit = {
     takeIO(function, pos)
   }
 
-  protected final def takeFunAny[T: Tag](function: T => Any, pos: CodePosition): Unit = {
+  protected final def takeFunAny[T: Tag](function: T => Any, pos: SourceFilePosition): Unit = {
     takeAny(function, pos)
   }
 }
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
index faec498d3..5059b03f4 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
@@ -24,7 +24,7 @@ import izumi.distage.testkit.services.dstest.TestEnvironment.{EnvExecutionParams
 import izumi.fundamentals.platform.cli.model.raw.RawAppArgs
 import izumi.fundamentals.platform.functional.Identity
 import izumi.fundamentals.platform.integration.ResourceCheck
-import izumi.fundamentals.platform.language.CodePosition
+import izumi.fundamentals.platform.language.SourceFilePosition
 import izumi.fundamentals.platform.strings.IzString._
 import izumi.logstage.api.logger.LogRouter
 import izumi.logstage.api.{IzLogger, Log}
@@ -249,7 +249,7 @@ class DistageTestRunner[F[_]: TagK](
     }
   }
 
-  protected def withRecoverFromFailedExecution_[A](allTests: => Iterable[DistageTest[F]])(f: => Unit): Unit =  {
+  protected def withRecoverFromFailedExecution_[A](allTests: => Iterable[DistageTest[F]])(f: => Unit): Unit = {
     withRecoverFromFailedExecution(allTests)(f)(())
   }
 
@@ -539,7 +539,7 @@ class DistageTestRunner[F[_]: TagK](
 object DistageTestRunner {
   final case class TestId(name: String, suiteName: String, suiteId: String, suiteClassName: String)
   final case class DistageTest[F[_]](test: ProviderMagnet[F[_]], environment: TestEnvironment, meta: TestMeta)
-  final case class TestMeta(id: TestId, pos: CodePosition, uid: Long)
+  final case class TestMeta(id: TestId, pos: SourceFilePosition, uid: Long)
   final case class SuiteData(suiteName: String, suiteId: String, suiteClassName: String)
 
   sealed trait TestStatus
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/TestRegistration.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/TestRegistration.scala
index b7edd4aeb..067137f28 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/TestRegistration.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/TestRegistration.scala
@@ -2,8 +2,8 @@ package izumi.distage.testkit.services.dstest
 
 import izumi.distage.model.providers.ProviderMagnet
 import izumi.distage.testkit.services.dstest.DistageTestRunner.TestId
-import izumi.fundamentals.platform.language.CodePosition
+import izumi.fundamentals.platform.language.SourceFilePosition
 
 trait TestRegistration[F[_]] {
-  def registerTest(function: ProviderMagnet[F[_]], env: TestEnvironment, pos: CodePosition, id: TestId): Unit
+  def registerTest(function: ProviderMagnet[F[_]], env: TestEnvironment, pos: SourceFilePosition, id: TestId): Unit
 }
diff --git a/distage/distage-testkit-scalatest/src/main/scala/izumi/distage/testkit/services/scalatest/dstest/DistageAbstractScalatestSpec.scala b/distage/distage-testkit-scalatest/src/main/scala/izumi/distage/testkit/services/scalatest/dstest/DistageAbstractScalatestSpec.scala
index 4b7f0d242..569177ea5 100644
--- a/distage/distage-testkit-scalatest/src/main/scala/izumi/distage/testkit/services/scalatest/dstest/DistageAbstractScalatestSpec.scala
+++ b/distage/distage-testkit-scalatest/src/main/scala/izumi/distage/testkit/services/scalatest/dstest/DistageAbstractScalatestSpec.scala
@@ -10,7 +10,7 @@ import izumi.distage.testkit.services.dstest._
 import izumi.distage.testkit.services.scalatest.dstest.DistageAbstractScalatestSpec._
 import izumi.distage.testkit.services.{DISyntaxBIOBase, DISyntaxBase}
 import izumi.functional.bio.BIOLocal
-import izumi.fundamentals.platform.language.{CodePosition, CodePositionMaterializer, unused}
+import izumi.fundamentals.platform.language.{SourceFilePosition, SourceFilePositionMaterializer, unused}
 import izumi.reflect.TagK3
 import org.scalactic.source
 import org.scalatest.Assertion
@@ -22,7 +22,7 @@ import scala.language.implicitConversions
 trait WithSingletonTestRegistration[F[_]] extends AbstractDistageSpec[F] {
   private[this] lazy val firstRegistration: Boolean = DistageTestsRegistrySingleton.registerSuite[F](this.getClass.getName)
 
-  override def registerTest(function: ProviderMagnet[F[_]], env: TestEnvironment, pos: CodePosition, id: TestId): Unit = {
+  override def registerTest(function: ProviderMagnet[F[_]], env: TestEnvironment, pos: SourceFilePosition, id: TestId): Unit = {
     if (firstRegistration) {
       DistageTestsRegistrySingleton.register[F](DistageTest(function, env, TestMeta(id, pos, System.identityHashCode(function).toLong)))
     }
@@ -68,23 +68,23 @@ object DistageAbstractScalatestSpec {
   }
 
   trait LowPriorityIdentityOverloads[F[_]] extends DISyntaxBase[F] {
-    def in(function: ProviderMagnet[Unit])(implicit pos: CodePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit): Unit = {
+    def in(function: ProviderMagnet[Unit])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit): Unit = {
       takeAny(function, pos.get)
     }
 
-    def in(function: ProviderMagnet[Assertion])(implicit pos: CodePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit, d3: DummyImplicit): Unit = {
+    def in(function: ProviderMagnet[Assertion])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit, d3: DummyImplicit): Unit = {
       takeAny(function, pos.get)
     }
 
-    def in(value: => Unit)(implicit pos: CodePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit): Unit = {
+    def in(value: => Unit)(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit): Unit = {
       takeAny(() => value, pos.get)
     }
 
-    def in(value: => Assertion)(implicit pos: CodePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit, d3: DummyImplicit): Unit = {
+    def in(value: => Assertion)(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit, d2: DummyImplicit, d3: DummyImplicit): Unit = {
       takeAny(() => value, pos.get)
     }
 
-    def skip(@unused value: => Any)(implicit pos: CodePositionMaterializer): Unit = {
+    def skip(@unused value: => Any)(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeFunIO(cancel, pos.get)
     }
 
@@ -108,9 +108,9 @@ object DistageAbstractScalatestSpec {
   ) extends DISyntaxBase[F]
     with LowPriorityIdentityOverloads[F] {
 
-    override protected def takeIO(function: ProviderMagnet[F[_]], pos: CodePosition): Unit = {
+    override protected def takeIO(function: ProviderMagnet[F[_]], pos: SourceFilePosition): Unit = {
       val id = TestId(
-        context.map(_.toName(testname)).getOrElse(testname),
+        context.fold(testname)(_.toName(testname)),
         suiteName,
         suiteId,
         suiteName,
@@ -118,19 +118,19 @@ object DistageAbstractScalatestSpec {
       reg.registerTest(function, env, pos, id)
     }
 
-    def in(function: ProviderMagnet[F[Unit]])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(function: ProviderMagnet[F[Unit]])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeIO(function, pos.get)
     }
 
-    def in(function: ProviderMagnet[F[Assertion]])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(function: ProviderMagnet[F[Assertion]])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeIO(function, pos.get)
     }
 
-    def in(value: => F[Unit])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(value: => F[Unit])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeIO(() => value, pos.get)
     }
 
-    def in(value: => F[Assertion])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(value: => F[Assertion])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeIO(() => value, pos.get)
     }
   }
@@ -147,9 +147,9 @@ object DistageAbstractScalatestSpec {
   ) extends DISyntaxBIOBase[F]
     with LowPriorityIdentityOverloads[F[Throwable, ?]] {
 
-    override protected def takeIO(fAsThrowable: ProviderMagnet[F[Throwable, _]], pos: CodePosition): Unit = {
+    override protected def takeIO(fAsThrowable: ProviderMagnet[F[Throwable, _]], pos: SourceFilePosition): Unit = {
       val id = TestId(
-        context.map(_.toName(testname)).getOrElse(testname),
+        context.fold(testname)(_.toName(testname)),
         suiteName,
         suiteId,
         suiteName,
@@ -157,19 +157,19 @@ object DistageAbstractScalatestSpec {
       reg.registerTest(fAsThrowable, env, pos, id)
     }
 
-    def in(function: ProviderMagnet[F[_, Unit]])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(function: ProviderMagnet[F[_, Unit]])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(function, pos.get)
     }
 
-    def in(function: ProviderMagnet[F[_, Assertion]])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(function: ProviderMagnet[F[_, Assertion]])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(function, pos.get)
     }
 
-    def in(value: => F[_, Unit])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(value: => F[_, Unit])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(() => value, pos.get)
     }
 
-    def in(value: => F[_, Assertion])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(value: => F[_, Assertion])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(() => value, pos.get)
     }
   }
@@ -186,9 +186,9 @@ object DistageAbstractScalatestSpec {
   ) extends DISyntaxBIOBase[F[Any, +?, +?]]
     with LowPriorityIdentityOverloads[F[Any, Throwable, ?]] {
 
-    override protected def takeIO(fAsThrowable: ProviderMagnet[F[Any, Throwable, _]], pos: CodePosition): Unit = {
+    override protected def takeIO(fAsThrowable: ProviderMagnet[F[Any, Throwable, _]], pos: SourceFilePosition): Unit = {
       val id = TestId(
-        context.map(_.toName(testname)).getOrElse(testname),
+        context.fold(testname)(_.toName(testname)),
         suiteName,
         suiteId,
         suiteName,
@@ -196,7 +196,7 @@ object DistageAbstractScalatestSpec {
       reg.registerTest(fAsThrowable, env, pos, id)
     }
 
-    def in[R: HasConstructor](function: ProviderMagnet[F[R, _, Unit]])(implicit pos: CodePositionMaterializer): Unit = {
+    def in[R: HasConstructor](function: ProviderMagnet[F[R, _, Unit]])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(
         function.zip(HasConstructor[R]).map2(ProviderMagnet.identity[BIOLocal[F]]) {
           case ((eff, r), f) => f.provide(eff)(r)
@@ -205,7 +205,7 @@ object DistageAbstractScalatestSpec {
       )
     }
 
-    def in[R: HasConstructor](function: ProviderMagnet[F[R, _, Assertion]])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in[R: HasConstructor](function: ProviderMagnet[F[R, _, Assertion]])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(
         function.zip(HasConstructor[R]).map2(ProviderMagnet.identity[BIOLocal[F]]) {
           case ((eff, r), f) => f.provide(eff)(r)
@@ -214,27 +214,27 @@ object DistageAbstractScalatestSpec {
       )
     }
 
-    def in[R: HasConstructor](value: => F[R, _, Unit])(implicit pos: CodePositionMaterializer): Unit = {
+    def in[R: HasConstructor](value: => F[R, _, Unit])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(ProviderMagnet.identity[BIOLocal[F]].map2(HasConstructor[R])(_.provide(value)(_)), pos.get)
     }
 
-    def in[R: HasConstructor](value: => F[R, _, Assertion])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in[R: HasConstructor](value: => F[R, _, Assertion])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(ProviderMagnet.identity[BIOLocal[F]].map2(HasConstructor[R])(_.provide(value)(_)), pos.get)
     }
 
-    def in(function: ProviderMagnet[F[Any, _, Unit]])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(function: ProviderMagnet[F[Any, _, Unit]])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(function, pos.get)
     }
 
-    def in(function: ProviderMagnet[F[Any, _, Assertion]])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(function: ProviderMagnet[F[Any, _, Assertion]])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(function, pos.get)
     }
 
-    def in(value: => F[Any, _, Unit])(implicit pos: CodePositionMaterializer): Unit = {
+    def in(value: => F[Any, _, Unit])(implicit pos: SourceFilePositionMaterializer): Unit = {
       takeBIO(() => value, pos.get)
     }
 
-    def in(value: => F[Any, _, Assertion])(implicit pos: CodePositionMaterializer, d1: DummyImplicit): Unit = {
+    def in(value: => F[Any, _, Assertion])(implicit pos: SourceFilePositionMaterializer, d1: DummyImplicit): Unit = {
       takeBIO(() => value, pos.get)
     }
   }
diff --git a/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestReporter.scala b/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestReporter.scala
index 9830e3427..7c9a8a323 100644
--- a/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestReporter.scala
+++ b/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestReporter.scala
@@ -47,63 +47,83 @@ class DistageScalatestReporter extends TestReporter {
 //      case TestStatus.Scheduled =>
 
       case TestStatus.Running =>
-        doReport(suiteId1)(TestStarting(
-          _,
-          suiteName1, suiteId1, Some(suiteClassName1),
-          testName,
-          testName,
-          location = Some(LineInFile(test.pos.position.line, test.pos.position.file, None)),
-          formatter = Some(MotionToSuppress),
-        ))
+        doReport(suiteId1)(
+          TestStarting(
+            _,
+            suiteName1,
+            suiteId1,
+            Some(suiteClassName1),
+            testName,
+            testName,
+            location = Some(LineInFile(test.pos.line, test.pos.file, None)),
+            formatter = Some(MotionToSuppress),
+          )
+        )
       case TestStatus.Succeed(duration) =>
-        doReport(suiteId1)(TestSucceeded(
-          _,
-          suiteName1, suiteId1, Some(suiteClassName1),
-          testName,
-          testName,
-          recordedEvents = Vector.empty,
-          duration = Some(duration.toMillis),
-          location = Some(LineInFile(test.pos.position.line, test.pos.position.file, None)),
-          formatter = formatter,
-        ))
+        doReport(suiteId1)(
+          TestSucceeded(
+            _,
+            suiteName1,
+            suiteId1,
+            Some(suiteClassName1),
+            testName,
+            testName,
+            recordedEvents = Vector.empty,
+            duration = Some(duration.toMillis),
+            location = Some(LineInFile(test.pos.line, test.pos.file, None)),
+            formatter = formatter,
+          )
+        )
       case TestStatus.Failed(t, duration) =>
-        doReport(suiteId1)(TestFailed(
-          _,
-          t.getMessage,
-          suiteName1, suiteId1, Some(suiteClassName1),
-          testName,
-          testName,
-          recordedEvents = Vector.empty,
-          analysis = Vector.empty,
-          throwable = Some(t),
-          duration = Some(duration.toMillis),
-          location = Some(LineInFile(test.pos.position.line, test.pos.position.file, None)),
-          formatter = formatter,
-        ))
+        doReport(suiteId1)(
+          TestFailed(
+            _,
+            t.getMessage,
+            suiteName1,
+            suiteId1,
+            Some(suiteClassName1),
+            testName,
+            testName,
+            recordedEvents = Vector.empty,
+            analysis = Vector.empty,
+            throwable = Some(t),
+            duration = Some(duration.toMillis),
+            location = Some(LineInFile(test.pos.line, test.pos.file, None)),
+            formatter = formatter,
+          )
+        )
       case TestStatus.Cancelled(clue, duration) =>
-        doReport(suiteId1)(TestCanceled(
-          _,
-          s"cancelled: $clue",
-          suiteName1, suiteId1, Some(suiteClassName1),
-          testName,
-          testName,
-          recordedEvents = Vector.empty,
-          duration = Some(duration.toMillis),
-          location = Some(LineInFile(test.pos.position.line, test.pos.position.file, None)),
-          formatter = formatter,
-        ))
+        doReport(suiteId1)(
+          TestCanceled(
+            _,
+            s"cancelled: $clue",
+            suiteName1,
+            suiteId1,
+            Some(suiteClassName1),
+            testName,
+            testName,
+            recordedEvents = Vector.empty,
+            duration = Some(duration.toMillis),
+            location = Some(LineInFile(test.pos.line, test.pos.file, None)),
+            formatter = formatter,
+          )
+        )
       case TestStatus.Ignored(checks) =>
-        doReport(suiteId1)(TestCanceled(
-          _,
-          s"ignored: ${checks.niceList()}",
-          suiteName1, suiteId1, Some(suiteClassName1),
-          testName,
-          testName,
-          recordedEvents = Vector.empty,
-          throwable = Some(new IntegrationCheckException(checks)),
-          formatter = formatter,
-          location = Some(LineInFile(test.pos.position.line, test.pos.position.file, None)),
-        ))
+        doReport(suiteId1)(
+          TestCanceled(
+            _,
+            s"ignored: ${checks.niceList()}",
+            suiteName1,
+            suiteId1,
+            Some(suiteClassName1),
+            testName,
+            testName,
+            recordedEvents = Vector.empty,
+            throwable = Some(new IntegrationCheckException(checks)),
+            formatter = formatter,
+            location = Some(LineInFile(test.pos.line, test.pos.file, None)),
+          )
+        )
     }
   }
 
diff --git a/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestTestSuiteRunner.scala b/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestTestSuiteRunner.scala
index 65ae7d49a..128b47a14 100644
--- a/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestTestSuiteRunner.scala
+++ b/distage/distage-testkit-scalatest/src/main/scala/org/scalatest/distage/DistageScalatestTestSuiteRunner.scala
@@ -105,7 +105,7 @@ abstract class DistageScalatestTestSuiteRunner[F[_]](implicit override val tagMo
     try {
       DistageTestsRegistrySingleton.proceedWithTests[F]() match {
         case Some(value) =>
-          _doRun(value, testName, args)
+          doRun(value, testName, args)
           if (!status.isCompleted) {
             status.setCompleted()
           }
@@ -157,7 +157,7 @@ abstract class DistageScalatestTestSuiteRunner[F[_]](implicit override val tagMo
     }
   }
 
-  protected[this] def _doRun(testsInThisRuntime: Seq[DistageTest[F]], testName: Option[String], args: Args): Unit = {
+  private[distage] def doRun(testsInThisRuntime: Seq[DistageTest[F]], testName: Option[String], args: Args): Unit = {
     val debugLogger: TrivialLogger = TrivialLogger.make[DistageScalatestTestSuiteRunner[F]](DebugProperties.`izumi.distage.testkit.debug`)
     debugLogger.log(s"Scalatest Args: $args")
     debugLogger.log(s"""tagsToInclude: ${args.filter.tagsToInclude}
@@ -165,7 +165,7 @@ abstract class DistageScalatestTestSuiteRunner[F[_]](implicit override val tagMo
                        |dynaTags: ${args.filter.dynaTags}
                        |excludeNestedSuites: ${args.filter.excludeNestedSuites}
                        |""".stripMargin)
-    val testReporter = _mkTestReporter()
+    val testReporter = mkTestReporter()
 
     val toRun = testName match {
       case None =>
@@ -196,7 +196,7 @@ abstract class DistageScalatestTestSuiteRunner[F[_]](implicit override val tagMo
     }
   }
 
-  protected[this] def _mkTestReporter(): TestReporter = {
+  private[distage] def mkTestReporter(): TestReporter = {
     val scalatestReporter = new DistageScalatestReporter
     new SafeTestReporter(scalatestReporter)
   }