Skip to content

Commit 3239399

Browse files
committed
Remove now-unused newSelf variable.
1 parent 856c193 commit 3239399

1 file changed

Lines changed: 30 additions & 35 deletions

File tree

sjsonnet/src/sjsonnet/Evaluator.scala

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -841,45 +841,40 @@ class Evaluator(
841841
def visitObjComp(e: ObjBody.ObjComp, sup: Val.Obj)(implicit scope: ValScope): Val.Obj = {
842842
val binds = e.preLocals ++ e.postLocals
843843
val compScope: ValScope = scope // .clearSuper
844-
845-
lazy val newSelf: Val.Obj = {
846-
val builder = new java.util.LinkedHashMap[String, Val.Obj.Member]
847-
for (s <- visitComp(e.first :: e.rest, Array(compScope))) {
848-
visitExpr(e.key)(s) match {
849-
case Val.Str(_, k) =>
850-
val prev_length = builder.size()
851-
builder.put(
852-
k,
853-
new Val.Obj.Member(e.plus, Visibility.Normal) {
854-
def invoke(self: Val.Obj, sup: Val.Obj, fs: FileScope, ev: EvalScope): Val = {
855-
lazy val newScope: ValScope = s.extend(newBindings, self, sup)
856-
lazy val newBindings = visitBindings(binds, (self, sup) => newScope)
857-
visitExpr(e.value)(
858-
s.extend(newBindings, self, null)
859-
)
860-
}
844+
val builder = new java.util.LinkedHashMap[String, Val.Obj.Member]
845+
for (s <- visitComp(e.first :: e.rest, Array(compScope))) {
846+
visitExpr(e.key)(s) match {
847+
case Val.Str(_, k) =>
848+
val prev_length = builder.size()
849+
builder.put(
850+
k,
851+
new Val.Obj.Member(e.plus, Visibility.Normal) {
852+
def invoke(self: Val.Obj, sup: Val.Obj, fs: FileScope, ev: EvalScope): Val = {
853+
lazy val newScope: ValScope = s.extend(newBindings, self, sup)
854+
lazy val newBindings = visitBindings(binds, (self, sup) => newScope)
855+
visitExpr(e.value)(
856+
s.extend(newBindings, self, null)
857+
)
861858
}
862-
)
863-
if (prev_length == builder.size() && settings.noDuplicateKeysInComprehension) {
864-
Error.fail(s"Duplicate key ${k} in evaluated object comprehension.", e.pos);
865859
}
866-
case Val.Null(_) => // do nothing
867-
case x =>
868-
Error.fail(
869-
s"Field name must be string or null, not ${x.prettyName}",
870-
e.pos
871-
)
872-
}
873-
}
874-
val valueCache = if (sup == null) {
875-
Val.Obj.getEmptyValueCacheForObjWithoutSuper(builder.size())
876-
} else {
877-
new java.util.HashMap[Any, Val]()
860+
)
861+
if (prev_length == builder.size() && settings.noDuplicateKeysInComprehension) {
862+
Error.fail(s"Duplicate key ${k} in evaluated object comprehension.", e.pos);
863+
}
864+
case Val.Null(_) => // do nothing
865+
case x =>
866+
Error.fail(
867+
s"Field name must be string or null, not ${x.prettyName}",
868+
e.pos
869+
)
878870
}
879-
new Val.Obj(e.pos, builder, false, null, sup, valueCache)
880871
}
881-
882-
newSelf
872+
val valueCache = if (sup == null) {
873+
Val.Obj.getEmptyValueCacheForObjWithoutSuper(builder.size())
874+
} else {
875+
new java.util.HashMap[Any, Val]()
876+
}
877+
new Val.Obj(e.pos, builder, false, null, sup, valueCache)
883878
}
884879

885880
@tailrec

0 commit comments

Comments
 (0)