From a1a4b9847e3b3d1f63d5c04c57f561708d009a34 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 17 Mar 2016 14:00:30 +0100 Subject: Initialize context in REPL This broke under the recent introduction of the JS backend, because now the context needs to be initialized before the platform can be selected. So invoking `doti` immediately gave an IllegalStateException. No big deal to fix, but it shows how sorely we are lacking REPL tests. --- src/dotty/tools/dotc/core/Contexts.scala | 2 +- src/dotty/tools/dotc/core/Definitions.scala | 2 +- src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 2fc958a49..fd0cff94e 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -544,7 +544,7 @@ object Contexts { */ def initialize()(implicit ctx: Context): Unit = { _platform = newPlatform - definitions.init + definitions.init() } def squashed(p: Phase): Phase = { diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 6f8a8f837..d8c882d5c 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -798,7 +798,7 @@ class Definitions { private[this] var _isInitialized = false private def isInitialized = _isInitialized - def init(implicit ctx: Context) = { + def init()(implicit ctx: Context) = { this.ctx = ctx if (!_isInitialized) { // force initialization of every symbol that is synthesized or hijacked by the compiler diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index 7d1da1419..dd7189ddf 100644 --- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -60,6 +60,8 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit import ast.untpd._ import CompilingInterpreter._ + ictx.base.initialize()(ictx) + /** directory to save .class files to */ val virtualDirectory = if (ictx.settings.d.isDefault(ictx)) new VirtualDirectory("(memory)", None) -- cgit v1.2.3