aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJon Pretty <jon.pretty@propensive.com>2017-06-23 14:20:40 +0200
committerJon Pretty <jon.pretty@propensive.com>2017-06-23 14:20:40 +0200
commit2fa873cd0322d21148cf01d94e485e04b03cdb7c (patch)
treead46dba1dfa747876cb0ee6f33e7c2163599511b /core
parentf8ce6450c7dc1985db8ac29312bd76d3295257ab (diff)
downloadmagnolia-2fa873cd0322d21148cf01d94e485e04b03cdb7c.tar.gz
magnolia-2fa873cd0322d21148cf01d94e485e04b03cdb7c.tar.bz2
magnolia-2fa873cd0322d21148cf01d94e485e04b03cdb7c.zip
Tidied up and made it compile and run
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/magnolia.scala19
1 files changed, 7 insertions, 12 deletions
diff --git a/core/src/main/scala/magnolia.scala b/core/src/main/scala/magnolia.scala
index 66d59d0..e2d1341 100644
--- a/core/src/main/scala/magnolia.scala
+++ b/core/src/main/scala/magnolia.scala
@@ -221,8 +221,8 @@ class Macros(val c: whitebox.Context) {
val contraDerivationType = appliedType(contraDerivationTypeclass, List(typeConstructor))
val contraDerivation2Type = appliedType(contraDerivation2Typeclass, List(typeConstructor))
- def findDerivationImplicit[T <: DerivationImplicit](tpe: c.Type, cons: Tree => T): Try[DerivationImplicit] =
- Try(cons(c.untypecheck(c.inferImplicitValue(tpe, false, false))))
+ def findDerivationImplicit[T <: DerivationImplicit](derivationType: c.Type, wrap: Tree => T): Try[DerivationImplicit] =
+ Try(wrap(c.untypecheck(c.inferImplicitValue(derivationType, false, false))))
val derivationImplicit =
findDerivationImplicit(coDerivationType, CovariantDerivationImplicit)
@@ -258,17 +258,12 @@ class Macros(val c: whitebox.Context) {
val searchType = appliedType(typeConstructor, genericType)
Some(q"_root_.magnolia.Lazy[$searchType]($methodAsString)")
}
- } else {
- directInferImplicit(genericType, typeConstructor, derivationImplicit)
- }
+ } else directInferImplicit(genericType, typeConstructor, derivationImplicit)
- if(currentStack.frames.isEmpty) recursionStack = Map()
+ if(currentStack.frames.isEmpty) recursionStack = ListMap()
result.map { tree =>
- if(currentStack.frames.isEmpty) {
- val res = c.untypecheck(removeLazy.transform(tree))
- res
- } else tree
+ if(currentStack.frames.isEmpty) c.untypecheck(removeLazy.transform(tree)) else tree
}.getOrElse {
c.abort(c.enclosingPosition, "could not infer typeclass for type $genericType")
}
@@ -312,8 +307,8 @@ private[magnolia] object CompileTimeState {
def termName(c: whitebox.Context): c.TermName = term.asInstanceOf[c.TermName]
}
- private[magnolia] var recursionStack: Map[api.Position, Stack] =
- Map()
+ private[magnolia] var recursionStack: ListMap[api.Position, Stack] =
+ ListMap()
private[magnolia] var emittedErrors: Set[ImplicitNotFound] = Set()
}