From 760df9843a910d6c3618e490c752eb03fb6924bd Mon Sep 17 00:00:00 2001 From: Den Shabalin Date: Fri, 6 Dec 2013 18:01:05 +0100 Subject: SI-8030 force symbols on presentation compiler initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit forces a number of built-in symbols in presentation compiler to prevent them from being entered during parsing. The property “parsing doesn’t enter new symbols” is tested on a rich source file that contains significant number of variations of Scala syntax. --- src/interactive/scala/tools/nsc/interactive/Global.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/interactive/scala/tools/nsc') diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index 467a210cab..cab5137a87 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -1234,6 +1234,18 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } } + // We need to force a number of symbols that might be touched by a parser. + // Otherwise thread safety property of parseTree method would be violated. + protected def forceSymbolsUsedByParser(): Unit = { + val symbols = + Set(UnitClass, BooleanClass, ByteClass, + ShortClass, IntClass, LongClass, FloatClass, + DoubleClass, NilModule, ListClass) ++ TupleClass.seq + symbols.foreach(_.initialize) + } + + forceSymbolsUsedByParser() + /** The compiler has been initialized. Constructors are evaluated in textual order, * so this is set to true only after all super constructors and the primary constructor * have been executed. -- cgit v1.2.3