Skip to content

Commit

Permalink
Merge pull request #10759 from lrytz/backport-10758
Browse files Browse the repository at this point in the history
Backport PR 10758 to 2.12
  • Loading branch information
lrytz committed Apr 17, 2024
2 parents 616e32f + f6fc121 commit a9c9962
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/library/scala/util/Properties.scala
Expand Up @@ -164,9 +164,10 @@ private[scala] trait PropertiesTrait {

/** System.console.isTerminal, or just check for null console on JDK < 22 */
private[scala] lazy val consoleIsTerminal: Boolean = {
import language.reflectiveCalls
val console = System.console
def isTerminal: Boolean =
try classOf[java.io.Console].getMethod("isTerminal", null).invoke(console).asInstanceOf[Boolean]
try console.asInstanceOf[{ def isTerminal(): Boolean }].isTerminal()
catch { case _: NoSuchMethodException => false }
console != null && (!isJavaAtLeast("22") || isTerminal)
}
Expand Down
3 changes: 1 addition & 2 deletions src/repl/scala/tools/nsc/interpreter/ILoop.scala
Expand Up @@ -29,7 +29,6 @@ import io.AbstractFile
import scala.concurrent.{Await, Future}
import java.io.BufferedReader

import scala.util.Properties.consoleIsTerminal
import scala.util.{Try, Success, Failure}

import Completion._
Expand Down Expand Up @@ -906,7 +905,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) extend
* supplied as a `() => Completion`; the Completion object provides a concrete Completer.
*/
def chooseReader(settings: Settings): InteractiveReader = {
if (settings.Xnojline || !consoleIsTerminal) SimpleReader()
if (settings.Xnojline) SimpleReader()
else {
type Completer = () => Completion
type ReaderMaker = Completer => InteractiveReader
Expand Down

0 comments on commit a9c9962

Please sign in to comment.