Skip to content

Commit

Permalink
Scala 3 Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurelineSwissBorg committed Sep 26, 2024
1 parent 52495e3 commit 88b7336
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions sjsonnet/src/sjsonnet/Evaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,20 @@ class Evaluator(resolver: CachedResolver,
def visitMemberList(objPos: Position, e: ObjBody.MemberList, sup: Val.Obj)(implicit scope: ValScope): Val.Obj = {
val asserts = e.asserts
val fields = e.fields
var cachedSimpleScope: ValScope = null.asInstanceOf[ValScope]
var cachedSimpleScope: ValScope | Null = null
var cachedObj: Val.Obj = null
var asserting: Boolean = false

def makeNewScope(self: Val.Obj, sup: Val.Obj): ValScope = {
if((sup eq null) && (self eq cachedObj)) {
if(cachedSimpleScope == null.asInstanceOf[ValScope]) cachedSimpleScope = createNewScope(self, sup)
cachedSimpleScope
cachedSimpleScope match {
case null =>
val cachedScope = createNewScope(self, sup)
cachedSimpleScope = cachedScope
cachedScope
case cachedScope: ValScope =>
cachedScope
}
} else createNewScope(self, sup)
}

Expand Down Expand Up @@ -581,7 +587,8 @@ class Evaluator(resolver: CachedResolver,
val v = new Val.Obj.Member(plus, sep) {
def invoke(self: Val.Obj, sup: Val.Obj, fs: FileScope, ev: EvalScope): Val = {
if(asserts != null) assertions(self)
visitExpr(rhs)(makeNewScope(self, sup))
val newScope = makeNewScope(self, sup)
visitExpr(rhs)(using newScope)
}
}
builder.put(k, v)
Expand Down
2 changes: 1 addition & 1 deletion sjsonnet/src/sjsonnet/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ class Interpreter(extVars: Map[String, String],
)
}
}
handleException(m.apply0(res, visitor)(evaluator))
handleException(m.apply0(res, visitor)(using evaluator))
}
}

0 comments on commit 88b7336

Please sign in to comment.