File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ class ReplCompiler(val directory: AbstractFile) extends Compiler {
146
146
* }
147
147
* ```
148
148
*/
149
- def wrapped (defs : Definitions ): untpd.PackageDef = {
149
+ def wrapped (defs : Definitions , sourceCode : String ): untpd.PackageDef = {
150
150
import untpd ._
151
151
152
152
implicit val ctx : Context = defs.state.run.runContext
@@ -156,7 +156,7 @@ class ReplCompiler(val directory: AbstractFile) extends Compiler {
156
156
List (
157
157
ModuleDef (objectName(defs.state), tmpl)
158
158
.withMods(new Modifiers (Module | Final ))
159
- .withPos(Position (defs.stats.head.pos.start, defs.stats.last.pos.end ))
159
+ .withPos(Position (0 , sourceCode.length ))
160
160
)
161
161
}
162
162
@@ -170,7 +170,7 @@ class ReplCompiler(val directory: AbstractFile) extends Compiler {
170
170
171
171
def createUnit (defs : Definitions , sourceCode : String ): Result [CompilationUnit ] = {
172
172
val unit = new CompilationUnit (new SourceFile (objectName(defs.state).toString, sourceCode))
173
- unit.untpdTree = wrapped(defs)
173
+ unit.untpdTree = wrapped(defs, sourceCode )
174
174
unit.result
175
175
}
176
176
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ class ReplDriver(settings: Array[String],
186
186
187
187
private def interpret (res : ParseResult )(implicit state : State ): State =
188
188
res match {
189
- case parsed : Parsed =>
189
+ case parsed : Parsed if parsed.trees.nonEmpty =>
190
190
compile(parsed)
191
191
.withHistory(parsed.sourceCode :: state.history)
192
192
.newRun(compiler, rootCtx)
@@ -195,9 +195,13 @@ class ReplDriver(settings: Array[String],
195
195
displayErrors(errs)
196
196
state.withHistory(src :: state.history)
197
197
198
- case Newline | SigKill => state
199
-
200
198
case cmd : Command => interpretCommand(cmd)
199
+
200
+ case SigKill => // TODO
201
+ state
202
+
203
+ case _ => // new line, empty tree
204
+ state
201
205
}
202
206
203
207
/** Compile `parsed` trees and evolve `state` in accordance */
Original file line number Diff line number Diff line change
1
+ scala> ;
2
+ scala> ;;
3
+ scala> 1; 2
4
+ val res0: Int = 1
5
+ val res1: Int = 2
6
+ scala> 1;
7
+ val res2: Int = 1
8
+ scala> 1;; 2
9
+ val res3: Int = 1
10
+ val res4: Int = 2
11
+ scala> }
12
+ 1 | }
13
+ | ^
14
+ | eof expected, but '}' found
You can’t perform that action at this time.
0 commit comments