Skip to content

Commit 119b788

Browse files
Merge branch 'master'
2 parents 70fcd52 + 385082b commit 119b788

File tree

431 files changed

+9688
-4922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+9688
-4922
lines changed

.drone.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ pipeline:
2323
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
2424
test:
2525
group: test
26-
image: lampepfl/dotty:2018-05-23
26+
image: lampepfl/dotty:2018-06-29
2727
commands:
2828
- cp -R . /tmp/1/ && cd /tmp/1/
2929
- ./project/scripts/sbt ";compile ;test"
3030
- ./project/scripts/cmdTests
3131

3232
test_bootstrapped:
3333
group: test
34-
image: lampepfl/dotty:2018-05-23
34+
image: lampepfl/dotty:2018-06-29
3535
commands:
3636
- cp -R . /tmp/2/ && cd /tmp/2/
3737
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
3838

3939
test_optimised:
4040
group: test
41-
image: lampepfl/dotty:2018-05-23
41+
image: lampepfl/dotty:2018-06-29
4242
commands:
4343
- cp -R . /tmp/3/ && cd /tmp/3/
4444
- ./project/scripts/sbt dotty-optimised/test
4545

4646
test_sbt:
4747
group: test
48-
image: lampepfl/dotty:2018-05-23
48+
image: lampepfl/dotty:2018-06-29
4949
commands:
5050
- cp -R . /tmp/4/ && cd /tmp/4/
5151
- ./project/scripts/sbt sbt-dotty/scripted
@@ -55,7 +55,7 @@ pipeline:
5555

5656
# DOCUMENTATION:
5757
documentation:
58-
image: lampepfl/dotty:2018-05-23
58+
image: lampepfl/dotty:2018-06-29
5959
commands:
6060
- ./project/scripts/genDocs
6161
secrets: [ bot_pass ]
@@ -67,7 +67,7 @@ pipeline:
6767
# PUBLISHING:
6868
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
6969
publish_nightly:
70-
image: lampepfl/dotty:2018-05-23
70+
image: lampepfl/dotty:2018-06-29
7171
environment:
7272
- NIGHTLYBUILD=yes
7373
commands:
@@ -78,7 +78,7 @@ pipeline:
7878
environment: nightly
7979

8080
publish_release:
81-
image: lampepfl/dotty:2018-05-23
81+
image: lampepfl/dotty:2018-06-29
8282
environment:
8383
- RELEASEBUILD=yes
8484
commands:
@@ -102,7 +102,7 @@ pipeline:
102102
event: tag
103103

104104
publish_sbt_release:
105-
image: lampepfl/dotty:2018-05-23
105+
image: lampepfl/dotty:2018-06-29
106106
environment:
107107
- RELEASEBUILD=yes
108108
commands:

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
258258
case t: TypeApply if (t.fun.symbol == Predef_classOf) =>
259259
av.visit(name, t.args.head.tpe.classSymbol.denot.info.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
260260
case t: tpd.Select =>
261-
if (t.symbol.denot.owner.is(Flags.Enum)) {
261+
if (t.symbol.denot.owner.is(Flags.JavaEnum)) {
262262
val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the enumeration class.
263263
val evalue = t.symbol.name.mangledString // value the actual enumeration value.
264264
av.visitEnum(name, edesc, evalue)
@@ -710,7 +710,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
710710
def isBottomClass: Boolean = (sym ne defn.NullClass) && (sym ne defn.NothingClass)
711711
def isBridge: Boolean = sym is Flags.Bridge
712712
def isArtifact: Boolean = sym is Flags.Artifact
713-
def hasEnumFlag: Boolean = sym is Flags.Enum
713+
def hasEnumFlag: Boolean = sym is Flags.JavaEnum
714714
def hasAccessBoundary: Boolean = sym.accessBoundary(defn.RootClass) ne defn.RootClass
715715
def isVarargsMethod: Boolean = sym is Flags.JavaVarargs
716716
def isDeprecated: Boolean = false
@@ -842,7 +842,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
842842
def superInterfaces: List[Symbol] = {
843843
val directlyInheritedTraits = decorateSymbol(sym).directlyInheritedTraits
844844
val directlyInheritedTraitsSet = directlyInheritedTraits.toSet
845-
val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.symbol.asClass.baseClasses.drop(1)).toSet
845+
val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.asClass.baseClasses.drop(1)).toSet
846846
val superCalls = superCallsMap.getOrElse(sym, Set.empty)
847847
val additional = (superCalls -- directlyInheritedTraitsSet).filter(_.is(Flags.Trait))
848848
// if (additional.nonEmpty)

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ class GenBCode extends Phase {
4141

4242
private[this] var myOutput: AbstractFile = _
4343

44-
protected def outputDir(implicit ctx: Context): AbstractFile = {
45-
if (myOutput eq null) {
46-
val path = Directory(ctx.settings.outputDir.value)
47-
myOutput =
48-
if (path.extension == "jar") JarArchive.create(path)
49-
else new PlainDirectory(path)
50-
}
44+
private def outputDir(implicit ctx: Context): AbstractFile = {
45+
if (myOutput eq null)
46+
myOutput = ctx.settings.outputDir.value
5147
myOutput
5248
}
5349

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ object CompilationUnit {
3737

3838
/** Make a compilation unit for top class `clsd` with the contends of the `unpickled` */
3939
def mkCompilationUnit(clsd: ClassDenotation, unpickled: Tree, forceTrees: Boolean)(implicit ctx: Context): CompilationUnit =
40-
mkCompilationUnit(new SourceFile(clsd.symbol.associatedFile, Seq()), unpickled, forceTrees)
40+
mkCompilationUnit(SourceFile(clsd.symbol.associatedFile, Array.empty), unpickled, forceTrees)
4141

4242
/** Make a compilation unit, given picked bytes and unpickled tree */
4343
def mkCompilationUnit(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(implicit ctx: Context): CompilationUnit = {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ class Compiler {
6060
protected def transformPhases: List[List[Phase]] =
6161
List(new FirstTransform, // Some transformations to put trees into a canonical form
6262
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
63-
new ProtectedAccessors, // Add accessors for protected members
6463
new ElimPackagePrefixes) :: // Eliminate references to package prefixes in Select nodes
6564
List(new CheckStatic, // Check restrictions that apply to @static members
6665
new ElimRepeated, // Rewrite vararg parameters and arguments
6766
new NormalizeFlags, // Rewrite some definition flags
68-
new ExtensionMethods, // Expand methods of value classes with extension methods
6967
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
68+
new ProtectedAccessors, // Add accessors for protected members
69+
new ExtensionMethods, // Expand methods of value classes with extension methods
7070
new ShortcutImplicits, // Allow implicit functions without creating closures
7171
new TailRec, // Rewrite tail recursion to loops
7272
new ByNameClosures, // Expand arguments to by-name parameters to closures

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package dotty.tools.dotc
22

33
import dotty.tools.FatalError
44
import config.CompilerCommand
5+
import core.Comments.{ContextDoc, ContextDocstrings}
56
import core.Contexts.{Context, ContextBase}
7+
import core.Mode
68
import util.DotClass
79
import reporting._
810
import scala.util.control.NonFatal
@@ -44,6 +46,11 @@ class Driver extends DotClass {
4446
val ctx = rootCtx.fresh
4547
val summary = CompilerCommand.distill(args)(ctx)
4648
ctx.setSettings(summary.sstate)
49+
50+
if (!ctx.settings.YdropComments.value(ctx) || ctx.mode.is(Mode.ReadComments)) {
51+
ctx.setProperty(ContextDoc, new ContextDocstrings)
52+
}
53+
4754
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ctx)
4855
(fileNames, ctx)
4956
}

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object desugar {
7878
case tp: NamedType if tp.symbol.exists && (tp.symbol.owner eq originalOwner) =>
7979
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next()
8080
var local = defctx.denotNamed(tp.name ++ suffix).suchThat(_.isParamOrAccessor).symbol
81-
if (local.exists) (defctx.owner.thisType select local).dealias
81+
if (local.exists) (defctx.owner.thisType select local).dealiasKeepAnnots
8282
else {
8383
def msg =
8484
s"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"
@@ -297,8 +297,8 @@ object desugar {
297297
val isCaseClass = mods.is(Case) && !mods.is(Module)
298298
val isCaseObject = mods.is(Case) && mods.is(Module)
299299
val isImplicit = mods.is(Implicit)
300-
val isEnum = mods.hasMod[Mod.Enum] && !mods.is(Module)
301-
val isEnumCase = mods.hasMod[Mod.EnumCase]
300+
val isEnum = mods.isEnumClass && !mods.is(Module)
301+
def isEnumCase = mods.isEnumCase
302302
val isValueClass = parents.nonEmpty && isAnyVal(parents.head)
303303
// This is not watertight, but `extends AnyVal` will be replaced by `inline` later.
304304

@@ -641,7 +641,7 @@ object desugar {
641641
val moduleName = checkNotReservedName(mdef).asTermName
642642
val impl = mdef.impl
643643
val mods = mdef.mods
644-
lazy val isEnumCase = mods.hasMod[Mod.EnumCase]
644+
def isEnumCase = mods.isEnumCase
645645
if (mods is Package)
646646
PackageDef(Ident(moduleName), cpy.ModuleDef(mdef)(nme.PACKAGE, impl).withMods(mods &~ Package) :: Nil)
647647
else if (isEnumCase)
@@ -688,7 +688,7 @@ object desugar {
688688
*/
689689
def patDef(pdef: PatDef)(implicit ctx: Context): Tree = flatTree {
690690
val PatDef(mods, pats, tpt, rhs) = pdef
691-
if (mods.hasMod[Mod.EnumCase])
691+
if (mods.isEnumCase)
692692
pats map {
693693
case id: Ident =>
694694
expandSimpleEnumCase(id.name.asTermName, mods,
@@ -810,16 +810,11 @@ object desugar {
810810
* ==>
811811
* def $anonfun(params) = body
812812
* Closure($anonfun)
813-
*
814-
* If `inlineable` is true, tag $anonfun with an @inline annotation.
815813
*/
816-
def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), inlineable: Boolean)(implicit ctx: Context) = {
817-
var mods = synthetic | Artifact
818-
if (inlineable) mods |= Inline
814+
def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), isImplicit: Boolean)(implicit ctx: Context) =
819815
Block(
820-
DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(mods),
821-
Closure(Nil, Ident(nme.ANON_FUN), EmptyTree))
822-
}
816+
DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(synthetic | Artifact),
817+
Closure(Nil, Ident(nme.ANON_FUN), if (isImplicit) ImplicitEmptyTree else EmptyTree))
823818

824819
/** If `nparams` == 1, expand partial function
825820
*
@@ -863,7 +858,7 @@ object desugar {
863858

864859
def makeImplicitFunction(formals: List[Type], body: Tree)(implicit ctx: Context): Tree = {
865860
val params = makeImplicitParameters(formals.map(TypeTree))
866-
new NonEmptyFunction(params, body, Modifiers(Implicit))
861+
new FunctionWithMods(params, body, Modifiers(Implicit))
867862
}
868863

869864
/** Add annotation to tree:
@@ -1114,8 +1109,8 @@ object desugar {
11141109
case Block(Nil, expr) => expr // important for interpolated string as patterns, see i1773.scala
11151110
case t => t
11161111
}
1117-
1118-
Apply(Select(Apply(Ident(nme.StringContext), strs), id), elems)
1112+
// This is a deliberate departure from scalac, where StringContext is not rooted (See #4732)
1113+
Apply(Select(Apply(scalaDot(nme.StringContext), strs), id), elems)
11191114
case InfixOp(l, op, r) =>
11201115
if (ctx.mode is Mode.Type)
11211116
AppliedTypeTree(op, l :: r :: Nil) // op[l, r]

compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ object DesugarEnums {
3333

3434
/** Is `tree` an (untyped) enum case? */
3535
def isEnumCase(tree: Tree)(implicit ctx: Context): Boolean = tree match {
36-
case tree: MemberDef => tree.mods.hasMod[Mod.EnumCase]
37-
case PatDef(mods, _, _, _) => mods.hasMod[Mod.EnumCase]
36+
case tree: MemberDef => tree.mods.isEnumCase
37+
case PatDef(mods, _, _, _) => mods.isEnumCase
3838
case _ => false
3939
}
4040

@@ -69,7 +69,7 @@ object DesugarEnums {
6969

7070
/** Add implied flags to an enum class or an enum case */
7171
def addEnumFlags(cdef: TypeDef)(implicit ctx: Context) =
72-
if (cdef.mods.hasMod[Mod.Enum]) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Abstract | Sealed))
72+
if (cdef.mods.isEnumClass) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Abstract | Sealed))
7373
else if (isEnumCase(cdef)) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Final))
7474
else cdef
7575

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,35 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
240240
case y => y
241241
}
242242

243+
/** The largest subset of {NoInits, PureInterface} that a
244+
* trait or class enclosing this statement can have as flags.
245+
*/
246+
def defKind(tree: Tree)(implicit ctx: Context): FlagSet = unsplice(tree) match {
247+
case EmptyTree | _: Import => NoInitsInterface
248+
case tree: TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
249+
case tree: DefDef =>
250+
if (tree.unforcedRhs == EmptyTree &&
251+
tree.vparamss.forall(_.forall(_.rhs.isEmpty))) NoInitsInterface
252+
else NoInits
253+
case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags
254+
case _ => EmptyFlags
255+
}
256+
257+
/** The largest subset of {NoInits, PureInterface} that a
258+
* trait or class with these parents can have as flags.
259+
*/
260+
def parentsKind(parents: List[Tree])(implicit ctx: Context): FlagSet = parents match {
261+
case Nil => NoInitsInterface
262+
case Apply(_, _ :: _) :: _ => EmptyFlags
263+
case _ :: parents1 => parentsKind(parents1)
264+
}
265+
266+
/** The largest subset of {NoInits, PureInterface} that a
267+
* trait or class with this body can have as flags.
268+
*/
269+
def bodyKind(body: List[Tree])(implicit ctx: Context): FlagSet =
270+
(NoInitsInterface /: body)((fs, stat) => fs & defKind(stat))
271+
243272
/** Checks whether predicate `p` is true for all result parts of this expression,
244273
* where we zoom into Ifs, Matches, and Blocks.
245274
*/
@@ -298,11 +327,15 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
298327

299328
/** Is `tree` an implicit function or closure, possibly nested in a block? */
300329
def isImplicitClosure(tree: Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
330+
case tree: FunctionWithMods => tree.mods.is(Implicit)
301331
case Function((param: untpd.ValDef) :: _, _) => param.mods.is(Implicit)
302332
case Closure(_, meth, _) => true
303333
case Block(Nil, expr) => isImplicitClosure(expr)
304-
case Block(DefDef(nme.ANON_FUN, _, (param :: _) :: _, _, _) :: Nil, _: Closure) =>
305-
param.mods.is(Implicit)
334+
case Block(DefDef(nme.ANON_FUN, _, params :: _, _, _) :: Nil, cl: Closure) =>
335+
params match {
336+
case param :: _ => param.mods.is(Implicit)
337+
case Nil => cl.tpt.eq(untpd.ImplicitEmptyTree) || defn.isImplicitFunctionType(cl.tpt.typeOpt)
338+
}
306339
case _ => false
307340
}
308341

@@ -354,6 +387,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
354387
refPurity(tree)
355388
case Select(qual, _) =>
356389
refPurity(tree).min(exprPurity(qual))
390+
case New(_) =>
391+
SimplyPure
357392
case TypeApply(fn, _) =>
358393
exprPurity(fn)
359394
/*
@@ -365,13 +400,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
365400
case Apply(fn, args) =>
366401
def isKnownPureOp(sym: Symbol) =
367402
sym.owner.isPrimitiveValueClass || sym.owner == defn.StringClass
368-
// Note: After uncurry, field accesses are represented as Apply(getter, Nil),
369-
// so an Apply can also be pure.
370-
if (args.isEmpty && fn.symbol.is(Stable)) exprPurity(fn)
371-
else if (tree.tpe.isInstanceOf[ConstantType] && isKnownPureOp(tree.symbol))
372-
// A constant expression with pure arguments is pure.
403+
if (tree.tpe.isInstanceOf[ConstantType] && isKnownPureOp(tree.symbol)
404+
// A constant expression with pure arguments is pure.
405+
|| fn.symbol.isStable)
373406
minOf(exprPurity(fn), args.map(exprPurity)) `min` Pure
374-
else Impure
407+
else
408+
Impure
375409
case Typed(expr, _) =>
376410
exprPurity(expr)
377411
case Block(stats, expr) =>
@@ -398,11 +432,16 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
398432
* @DarkDimius: need to make sure that lazy accessor methods have Lazy and Stable
399433
* flags set.
400434
*/
401-
def refPurity(tree: Tree)(implicit ctx: Context): PurityLevel =
402-
if (!tree.tpe.widen.isParameterless || tree.symbol.is(Erased)) SimplyPure
403-
else if (!tree.symbol.isStable) Impure
404-
else if (tree.symbol.is(Lazy)) Idempotent // TODO add Module flag, sinxce Module vals or not Lazy from the start.
435+
def refPurity(tree: Tree)(implicit ctx: Context): PurityLevel = {
436+
val sym = tree.symbol
437+
if (!tree.hasType) Impure
438+
else if (!tree.tpe.widen.isParameterless || sym.is(Erased)) SimplyPure
439+
else if (!sym.isStable) Impure
440+
else if (sym.is(Module))
441+
if (sym.moduleClass.isNoInitsClass) Pure else Idempotent
442+
else if (sym.is(Lazy)) Idempotent
405443
else SimplyPure
444+
}
406445

407446
def isPureRef(tree: Tree)(implicit ctx: Context) =
408447
refPurity(tree) == SimplyPure
@@ -547,6 +586,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
547586
/** An extractor for def of a closure contained the block of the closure. */
548587
object closureDef {
549588
def unapply(tree: Tree): Option[DefDef] = tree match {
589+
case Block(Nil, expr) => unapply(expr)
550590
case Block((meth @ DefDef(nme.ANON_FUN, _, _, _, _)) :: Nil, closure: Closure) =>
551591
Some(meth)
552592
case _ => None
@@ -618,17 +658,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
618658
accum(Nil, root)
619659
}
620660

621-
/** The largest subset of {NoInits, PureInterface} that a
622-
* trait enclosing this statement can have as flags.
623-
*/
624-
def defKind(tree: Tree): FlagSet = unsplice(tree) match {
625-
case EmptyTree | _: Import => NoInitsInterface
626-
case tree: TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
627-
case tree: DefDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else NoInits
628-
case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags
629-
case _ => EmptyFlags
630-
}
631-
632661
/** The top level classes in this tree, including only those module classes that
633662
* are not a linked class of some other class in the result.
634663
*/

0 commit comments

Comments
 (0)