Github user ScrapCodes commented on a diff in the pull request: https://github.com/apache/spark/pull/11410#discussion_r54401926 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala --- @@ -39,4 +41,35 @@ object OuterScopes { def addOuterScope(outer: AnyRef): Unit = { outerScopes.putIfAbsent(outer.getClass.getName, outer) } + + def getOuterScope(innerCls: Class[_]): AnyRef = { + assert(innerCls.isMemberClass) + val outerCls = innerCls.getDeclaringClass.getName + val outer = outerScopes.get(outerCls) + if (outer == null) { + outerCls match { + case REPLClass(line) => + val loader = Utils.getContextOrSparkClassLoader + def loadCls(clsName: String): Class[_] = Class.forName(clsName, true, loader) + + val cls1 = loadCls(line + "$read$") + val obj1 = cls1.getField("MODULE$").get(null) + + val obj2 = cls1.getMethod("INSTANCE").invoke(obj1) + val cls2 = loadCls(line + "$read") + + val obj3 = cls2.getMethod("$iw").invoke(obj2) + val cls3 = loadCls(line + "$read$$iw") + + cls3.getMethod("$iw").invoke(obj3) + + case _ => null + } + } else { + outer + } + } + + // The format of REPL generated wrapper class's name, e.g. `$line12.$read$$iw$$iw` --- End diff -- AFAIK this is going to be okay, and very less likely to change I suppose. I have not tested your change. This is an interesting patch, I will spend more time looking at it.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org