Skip to content

Always run the compiler with a bootstrapped dotty-library #4833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/Bench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package dotc
import core.Contexts.Context
import reporting.Reporter

import scala.annotation.internal.sharable

/** A main class for running compiler benchmarks. Can instantiate a given
* number of compilers and run each (sequentially) a given number of times
* on the same sources.
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import collection.mutable.ListBuffer
import reporting.diagnostic.messages._
import reporting.trace

import scala.annotation.internal.sharable

object desugar {
import untpd._
import DesugarEnums._
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import collection.mutable.ListBuffer
import util.Property
import typer.ErrorReporting._

import scala.annotation.internal.sharable

/** Helper methods to desugar enums */
object DesugarEnums {
import untpd._
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import parsing.Tokens.Token
import printing.Printer
import util.{Stats, Attachment, Property, DotClass}
import config.Config
import annotation.internal.sharable
import annotation.unchecked.uncheckedVariance
import language.implicitConversions

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import language.higherKinds
import collection.mutable.ListBuffer
import reflect.ClassTag

import scala.annotation.internal.sharable

object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

// ----- Tree cases that exist in untyped form only ------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc
package config

import scala.annotation.tailrec
import dotty.tools.sharable
import scala.annotation.internal.sharable

/** A simple (overly so) command line parser.
* !!! This needs a thorough test suite to make sure quoting is
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/config/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dotty.tools
package dotc
package config

import scala.annotation.internal.sharable

import java.io.{ IOException, PrintWriter }
import java.util.jar.Attributes.{ Name => AttributeName }

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ScalaSettings extends Settings.SettingGroup {
val YlogClasspath = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.")
val YdisableFlatCpCaching = BooleanSetting("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")

val Yscala2Unpickler = StringSetting("-Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")

val YnoImports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
val YnoInline = BooleanSetting("-Yno-inline", "Suppress inlining.")
val YnoGenericSig = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.")
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package dotty.tools
package dotc.config

import scala.annotation.internal.sharable
import scala.util.{Try, Success, Failure}

/**
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import collection.immutable.BitSet
import printing._
import config.{JavaPlatform, Platform, ScalaSettings, Settings}

import scala.annotation.internal.sharable

import language.implicitConversions
import DenotTransformers.DenotTransformer
import dotty.tools.dotc.profile.Profiler
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/NameKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Decorators._
import Contexts.Context
import collection.mutable

import scala.annotation.internal.sharable

/** Defines possible kinds of NameInfo of a derived name */
object NameKinds {

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import util.{DotClass}
import config.Config
import java.util.HashMap

import scala.annotation.internal.sharable

object Names {
import NameKinds._

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import reporting.diagnostic.Message
import reporting.diagnostic.messages.BadSymbolicReference
import reporting.trace

import scala.annotation.internal.sharable

trait SymDenotations { this: Context =>
import SymDenotations._

Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.AbstractFile
import language.implicitConversions
import util.{NoSource, DotClass, Property}
import scala.collection.JavaConverters._
import scala.annotation.internal.sharable
import config.Printers.typr

/** Creation methods for symbols */
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import ast.tpd._
import reporting.trace
import reporting.diagnostic.Message

import scala.annotation.internal.sharable

trait TypeOps { this: Context => // TODO: Make standalone object.

/** The type `tp` as seen from prefix `pre` and owner `cls`. See the spec
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TyperState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import collection.mutable
import java.lang.ref.WeakReference
import Decorators._

import scala.annotation.internal.sharable

object TyperState {
@sharable private var nextId: Int = 0
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import scala.util.hashing.{ MurmurHash3 => hashing }
import config.Printers.{core, typr}
import java.lang.ref.WeakReference

import scala.annotation.internal.sharable

object Types {

@sharable private[this] var nextId = 0
Expand Down
14 changes: 14 additions & 0 deletions compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,20 @@ class ClassfileParser(
}

def unpickleScala(bytes: Array[Byte]): Some[Embedded] = {
val allowed = ctx.settings.Yscala2Unpickler.value

def failUnless(cond: Boolean) =
assert(cond,
s"Unpickling ${classRoot.symbol.showLocated} from ${classRoot.symbol.associatedFile} is not allowed with -Yscala2-unpickler $allowed")

if (allowed != "always") {
failUnless(allowed != "never")
val allowedList = allowed.split(":").toList
val file = classRoot.symbol.associatedFile
// Using `.toString.contains` isn't great, but it's good enough for a debug flag.
failUnless(file == null || allowedList.exists(path => file.toString.contains(path)))
}

val unpickler = new unpickleScala2.Scala2Unpickler(bytes, classRoot, moduleRoot)(ctx)
unpickler.run()(ctx.addMode(Scala2UnpicklingMode))
Some(unpickler)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import scala.quoted
import scala.quoted.Types.TreeType
import scala.quoted.Exprs.TastyTreeExpr

import scala.annotation.internal.sharable

/** Unpickler for typed trees
* @param reader the reader from which to unpickle
* @param posUnpicklerOpt the unpickler for positions, if it exists
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dotty.tools
package dotc
package parsing

import scala.annotation.internal.sharable
import scala.collection.mutable.ListBuffer
import scala.collection.immutable.BitSet
import util.{ SourceFile, SourcePosition }
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/printing/Printer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Types.Type, Symbols.Symbol, Contexts.Context, Scopes.Scope, Constants.Con
import typer.Implicits.SearchResult
import typer.ImportInfo

import scala.annotation.internal.sharable

/** The base class of all printers
*/
abstract class Printer {
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dotty.tools
package dotc
package reporting

import scala.annotation.internal.sharable

import core.Contexts._
import util.{SourcePosition, NoSourcePosition}
import core.Decorators.PhaseListDecorator
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/CheckReentrant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class CheckReentrant extends MiniPhase {
private[this] var indent: Int = 0

private val sharableAnnot = new CtxLazy(implicit ctx =>
ctx.requiredClass("dotty.tools.sharable"))
ctx.requiredClass("scala.annotation.internal.sharable"))
private val unsharedAnnot = new CtxLazy(implicit ctx =>
ctx.requiredClass("dotty.tools.unshared"))
ctx.requiredClass("scala.annotation.internal.unshared"))

def isIgnored(sym: Symbol)(implicit ctx: Context) =
sym.hasAnnotation(sharableAnnot()) ||
Expand Down Expand Up @@ -92,4 +92,4 @@ class CheckReentrant extends MiniPhase {
addVars(tree.symbol.owner.asClass)
tree
}
}
}
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import config.Printers.{implicits, implicitsDetailed, typr}
import collection.mutable
import reporting.trace

import scala.annotation.internal.sharable

/** Implicit resolution */
object Implicits {
import tpd._
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import reporting._
import collection.mutable
import config.Config

import scala.annotation.internal.sharable

object Inferencing {

import tpd._
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import ErrorReporting.errorType
import config.Printers.typr
import collection.mutable

import scala.annotation.internal.sharable

object ProtoTypes {

import tpd._
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/util/NameTransformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import core.Decorators._
import collection.mutable
import util.Chars.isValidJVMMethodChar

import scala.annotation.internal.sharable

/** Provides functions to encode and decode Scala symbolic names.
*/
object NameTransformer {
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Chars._
import ScriptSourceFile._
import Positions._
import scala.io.Codec
import scala.annotation.internal.sharable

import java.util.Optional

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/util/SourcePosition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package util

import Positions.{Position, NoPosition}

import scala.annotation.internal.sharable

/** A source position is comprised of a position in a source file */
case class SourcePosition(source: SourceFile, pos: Position, outer: SourcePosition = NoSourcePosition)
extends interfaces.SourcePosition {
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/util/Stats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dotty.tools
package dotc
package util

import scala.annotation.internal.sharable

import core.Contexts._
import collection.mutable

Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package dotty
import scala.annotation.Annotation

package object tools {
class sharable extends Annotation
class unshared extends Annotation

// Ensure this object is already classloaded, since it's only actually used
// when handling stack overflows and every operation (including class loading)
// risks failing.
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/repl/ParseResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import dotc.reporting._

import results._

import scala.annotation.internal.sharable

/** A parsing result from string input */
sealed trait ParseResult

Expand Down
4 changes: 4 additions & 0 deletions compiler/test/dotty/Jars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ object Jars {
lazy val scalaAsm: String =
findJarFromRuntime("scala-asm-6.0.0-scala-1")

/** scala-xml jar */
lazy val scalaXml: String =
findJarFromRuntime("scala-xml")

/** JLine Jar */
lazy val jline: String =
findJarFromRuntime("jline-3.7.0")
Expand Down
3 changes: 3 additions & 0 deletions compiler/test/dotty/TestCategories.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ trait SlowTests

/** Meta tests category for JUnit */
trait VulpixMetaTests

/** Tests that should only be run with a bootstrapped compiler */
trait BootstrappedOnlyTests
Loading