Skip to content

Commit d761815

Browse files
authored
Merge pull request #4757 from dotty-staging/repl
Small cleanup in REPL Compiler
2 parents 94d8e94 + 4acd997 commit d761815

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

compiler/src/dotty/tools/repl/ReplCompiler.scala

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class ReplCompiler extends Compiler {
114114

115115
val tmpl = Template(emptyConstructor, Nil, EmptyValDef, defs.stats)
116116
val module = ModuleDef(objectName(defs.state), tmpl)
117-
.withMods(Modifiers(Module | Final))
118117
.withPos(Position(0, defs.stats.last.pos.end))
119118

120119
PackageDef(Ident(nme.EMPTY_PACKAGE), List(module))
@@ -156,22 +155,15 @@ class ReplCompiler extends Compiler {
156155
final def typeCheck(expr: String, errorsAllowed: Boolean = false)(implicit state: State): Result[tpd.ValDef] = {
157156

158157
def wrapped(expr: String, sourceFile: SourceFile, state: State)(implicit ctx: Context): Result[untpd.PackageDef] = {
159-
def wrap(trees: Seq[untpd.Tree]): untpd.PackageDef = {
158+
def wrap(trees: List[untpd.Tree]): untpd.PackageDef = {
160159
import untpd._
161160

162-
val valdef =
163-
ValDef("expr".toTermName, TypeTree(), Block(trees.toList, untpd.unitLiteral))
164-
165-
val tmpl = Template(emptyConstructor,
166-
List(Ident(tpnme.Any)),
167-
EmptyValDef,
168-
state.imports :+ valdef)
169-
170-
PackageDef(Ident(nme.EMPTY_PACKAGE),
171-
TypeDef("EvaluateExpr".toTypeName, tmpl)
172-
.withMods(Modifiers(Final))
173-
.withPos(Position(0, expr.length)) :: Nil
174-
)
161+
val valdef = ValDef("expr".toTermName, TypeTree(), Block(trees, unitLiteral))
162+
val tmpl = Template(emptyConstructor, Nil, EmptyValDef, state.imports :+ valdef)
163+
val wrapper = TypeDef("$wrapper".toTypeName, tmpl)
164+
.withMods(Modifiers(Final))
165+
.withPos(Position(0, expr.length))
166+
PackageDef(Ident(nme.EMPTY_PACKAGE), List(wrapper))
175167
}
176168

177169
ParseResult(expr) match {

0 commit comments

Comments
 (0)