diff options
author | Georgi Krastev <joro.kr.21@gmail.com> | 2018-04-14 23:49:40 +0200 |
---|---|---|
committer | Georgi Krastev <joro.kr.21@gmail.com> | 2018-04-14 23:53:16 +0200 |
commit | 60254ec97e06ffe0e460ab02240d03b26271a9c3 (patch) | |
tree | 65e3caf039cbc4cb85505873e0bda00d89c4e28d | |
parent | b2c4b2c345a8ac82bbf3240cc41b248b07924705 (diff) | |
download | magnolia-60254ec97e06ffe0e460ab02240d03b26271a9c3.tar.gz magnolia-60254ec97e06ffe0e460ab02240d03b26271a9c3.tar.bz2 magnolia-60254ec97e06ffe0e460ab02240d03b26271a9c3.zip |
Simplify Stack.trace implementation
-rw-r--r-- | core/shared/src/main/scala/magnolia.scala | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/core/shared/src/main/scala/magnolia.scala b/core/shared/src/main/scala/magnolia.scala index a9e231a..be4c65e 100644 --- a/core/shared/src/main/scala/magnolia.scala +++ b/core/shared/src/main/scala/magnolia.scala @@ -14,6 +14,7 @@ */ package magnolia +import scala.collection.breakOut import scala.collection.mutable import scala.language.existentials import scala.language.higherKinds @@ -519,17 +520,10 @@ private[magnolia] object CompileTimeState { } def trace: List[TypePath] = - frames - .drop(1) - .foldLeft[(C#Type, List[TypePath])]((null, Nil)) { - case ((_, Nil), frame) => - (frame.searchType, frame.path :: Nil) - case (continue @ (tpe, acc), frame) => - if (tpe =:= frame.searchType) continue - else (frame.searchType, frame.path :: acc) - } - ._2 - .reverse + (frames.drop(1), frames).zipped.collect { + case (Frame(path, tp1, _), Frame(_, tp2, _)) + if !(tp1 =:= tp2) => path + } (breakOut) override def toString: String = frames.mkString("magnolia stack:\n", "\n", "\n") |