Skip to content

Commit 763bb08

Browse files
committed
Add ReplCompilationUnit
1 parent 8497e46 commit 763bb08

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import typer.Nullables
1414
import transform.SymUtils._
1515
import core.Decorators.{given _}
1616
import config.SourceVersion
17-
import StdNames.str
1817

1918
class CompilationUnit protected (val source: SourceFile) {
2019

@@ -27,9 +26,6 @@ class CompilationUnit protected (val source: SourceFile) {
2726
/** Is this the compilation unit of a Java file */
2827
def isJava: Boolean = source.file.name.endsWith(".java")
2928

30-
/** Is this the compilation unit of a REPL input */
31-
def isREPL: Boolean = source.file.name.startsWith(str.REPL_SESSION_LINE)
32-
3329
/** The source version for this unit, as determined by a language import */
3430
var sourceVersion: Option[SourceVersion] = None
3531

@@ -53,7 +49,7 @@ class CompilationUnit protected (val source: SourceFile) {
5349
var suspended: Boolean = false
5450

5551
/** Can this compilation unit be suspended */
56-
def isSuspendable: Boolean = !isREPL
52+
def isSuspendable: Boolean = true
5753

5854
/** Suspends the compilation unit by thowing a SuspendException
5955
* and recoring the suspended compilation unit

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class ReplCompiler extends Compiler {
146146
val objectTermName = ctx.source.file.toString.toTermName
147147
objectNames.update(defs.state.objectIndex, objectTermName)
148148

149-
val unit = CompilationUnit(ctx.source)
149+
val unit = new ReplCompilationUnit(ctx.source)
150150
unit.untpdTree = wrapped(defs, objectTermName, span)
151151
unit
152152
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package dotty.tools.repl
2+
3+
import dotty.tools.dotc.CompilationUnit
4+
import dotty.tools.dotc.util.SourceFile
5+
6+
7+
class ReplCompilationUnit(source: SourceFile) extends CompilationUnit(source):
8+
override def isSuspendable: Boolean = false

0 commit comments

Comments
 (0)