You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jsoniter-scala-macros/shared/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala
// Borrowed and refactored from Chimney: https://github.com/scalalandio/chimney/blob/master/chimney/src/main/scala/io/scalaland/chimney/internal/CompanionUtils.scala#L10-L63
445
-
// Copied from Magnolia: https://github.com/propensive/magnolia/blob/master/core/shared/src/main/scala/globalutil.scala
446
-
// From Shapeless: https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/generic.scala#L698
447
-
// Cut-n-pasted (with most original comments) and slightly adapted from https://github.com/scalamacros/paradise/blob/c14c634923313dd03f4f483be3d7782a9b56de0e/plugin/src/main/scala/org/scalamacros/paradise/typechecker/Namers.scala#L568-L613
// NOTE: original implementation says `val s = ctx.scope lookup name`
460
-
// but we can't use it, because Scope.lookup returns wrong results when the lookup is ambiguous
461
-
// and that triggers https://github.com/scalamacros/paradise/issues/64
462
-
vals= ctx.scope.lookupAll(name)
463
-
.filter(sym => (original.isTerm || sym.hasModuleFlag) && sym.isCoDefinedWith(original)).toList match {
464
-
caseNil=>NoSymbol
465
-
case unique ::Nil=> unique
466
-
case _ => fail(s"Unexpected multiple results for a companion symbol lookup for $original")
467
-
}
468
-
if (s !=NoSymbol&& s.owner == expectedOwner) res = s
469
-
else ctx = ctx.outer
470
-
}
471
-
res
472
-
}).asInstanceOf[Tree]
473
-
}
474
-
475
444
valcomp= tpe.typeSymbol.companion
476
445
if (comp.isModule) comp
477
-
else patchedCompanionRef(tpe).symbol
446
+
else {
447
+
// Borrowed from Magnolia: https://github.com/propensive/magnolia/blob/f21f2aabb49e43b372240e98ec77981662cc570c/core/shared/src/main/scala/magnolia.scala#L123-L155
448
+
valownerChainOf:Symbol=>Iterator[Symbol] =
449
+
s =>Iterator.iterate(s)(_.owner).takeWhile(x => x !=null&& x !=NoSymbol).toVector.reverseIterator
0 commit comments