Skip to content

Commit 096d0d3

Browse files
committed
Merge branch 'master' into 'topic/sbt1'
2 parents a15d0cd + 84bf2fa commit 096d0d3

File tree

120 files changed

+1476
-337
lines changed

Some content is hidden

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

120 files changed

+1476
-337
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Compiler {
8181
new CrossCastAnd, // Normalize selections involving intersection types.
8282
new Splitter) :: // Expand selections involving union types into conditionals
8383
List(new ErasedDecls, // Removes all erased defs and vals decls (except for parameters)
84+
new IsInstanceOfChecker, // check runtime realisability for `isInstanceOf`
8485
new VCInlineMethods, // Inlines calls to value class methods
8586
new SeqLiterals, // Express vararg arguments as arrays
8687
new InterceptedMethods, // Special handling of `==`, `|=`, `getClass` methods

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ object desugar {
429429
}
430430
val hasRepeatedParam = constrVparamss.exists(_.exists {
431431
case ValDef(_, tpt, _) => isRepeated(tpt)
432-
case _ => false
433432
})
434433
if (mods.is(Abstract) || hasRepeatedParam) Nil // cannot have default arguments for repeated parameters, hence copy method is not issued
435434
else {
@@ -805,7 +804,7 @@ object desugar {
805804
* If `inlineable` is true, tag $anonfun with an @inline annotation.
806805
*/
807806
def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), inlineable: Boolean)(implicit ctx: Context) = {
808-
var mods = synthetic
807+
var mods = synthetic | Artifact
809808
if (inlineable) mods |= Inline
810809
Block(
811810
DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(mods),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ object Trees {
771771
def flatten[T >: Untyped](trees: List[Tree[T]]): List[Tree[T]] = {
772772
var buf: ListBuffer[Tree[T]] = null
773773
var xs = trees
774-
while (xs.nonEmpty) {
774+
while (!xs.isEmpty) {
775775
xs.head match {
776776
case Thicket(elems) =>
777777
if (buf == null) {
@@ -805,7 +805,7 @@ object Trees {
805805
def unforced: AnyRef
806806
protected def force(x: AnyRef): Unit
807807
def forceIfLazy(implicit ctx: Context): T = unforced match {
808-
case lzy: Lazy[T] =>
808+
case lzy: Lazy[T @unchecked] =>
809809
val x = lzy.complete
810810
force(x)
811811
x

compiler/src/dotty/tools/dotc/config/Properties.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ trait PropertiesTrait {
5656
def scalaPropOrElse(name: String, alt: String): String = scalaProps.getProperty(name, alt)
5757
def scalaPropOrEmpty(name: String): String = scalaPropOrElse(name, "")
5858
def scalaPropOrNone(name: String): Option[String] = Option(scalaProps.getProperty(name))
59-
59+
6060
/** Either the development or release version if known, otherwise
6161
* the empty string.
6262
*/
@@ -73,7 +73,15 @@ trait PropertiesTrait {
7373
} else ""
7474
}
7575
}
76-
76+
77+
/** Whether the current version of compiler is experimental
78+
*
79+
* 1. Snapshot and nightly releases are experimental.
80+
* 2. Features supported by experimental versions of the compiler:
81+
* - research plugins
82+
*/
83+
val experimental = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY")
84+
7785
val copyrightString = scalaPropOrElse("copyright.string", "(c) 2002-2017 LAMP/EPFL")
7886

7987
/** This is the encoding to use reading in source files, overridden with -encoding

compiler/src/dotty/tools/dotc/core/Hashable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ trait Hashable {
6464
var h = seed
6565
var xs = tps
6666
var len = arity
67-
while (xs.nonEmpty) {
67+
while (!xs.isEmpty) {
6868
val elemHash = typeHash(bs, xs.head)
6969
if (elemHash == NotCached) return NotCached
7070
h = hashing.mix(h, elemHash)

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,15 @@ object Names {
547547
private[this] var size = 1
548548

549549
/** The hash of a name made of from characters cs[offset..offset+len-1]. */
550-
private def hashValue(cs: Array[Char], offset: Int, len: Int): Int =
551-
if (len > 0)
552-
(len * (41 * 41 * 41) +
553-
cs(offset) * (41 * 41) +
554-
cs(offset + len - 1) * 41 +
555-
cs(offset + (len >> 1)))
556-
else 0
550+
private def hashValue(cs: Array[Char], offset: Int, len: Int): Int = {
551+
var i = offset
552+
var hash = 0
553+
while (i < len + offset) {
554+
hash = 31 * hash + cs(i)
555+
i += 1
556+
}
557+
hash
558+
}
557559

558560
/** Is (the ASCII representation of) name at given index equal to
559561
* cs[offset..offset+len-1]?

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -519,23 +519,17 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
519519
def mergeParams(ps1: List[TypeParamRef], ps2: List[TypeParamRef]) =
520520
(ps1 /: ps2)((ps1, p2) => if (ps1.contains(p2)) ps1 else p2 :: ps1)
521521

522-
def mergeEntries(e1: Type, e2: Type): Type = e1 match {
523-
case e1: TypeBounds =>
524-
e2 match {
525-
case e2: TypeBounds => e1 & e2
526-
case _ if e1 contains e2 => e2
527-
case _ => mergeError
528-
}
529-
case tv1: TypeVar =>
530-
e2 match {
531-
case tv2: TypeVar if tv1.instanceOpt eq tv2.instanceOpt => e1
532-
case _ => mergeError
533-
}
522+
// Must be symmetric
523+
def mergeEntries(e1: Type, e2: Type): Type =
524+
(e1, e2) match {
534525
case _ if e1 eq e2 => e1
535-
case _ => mergeError
536-
}
537-
538-
def mergeError = throw new AssertionError(i"cannot merge $this with $other")
526+
case (e1: TypeBounds, e2: TypeBounds) => e1 & e2
527+
case (e1: TypeBounds, _) if e1 contains e2 => e2
528+
case (_, e2: TypeBounds) if e2 contains e1 => e1
529+
case (tv1: TypeVar, tv2: TypeVar) if tv1.instanceOpt eq tv2.instanceOpt => e1
530+
case _ =>
531+
throw new AssertionError(i"cannot merge $this with $other, mergeEntries($e1, $e2) failed")
532+
}
539533

540534
val that = other.asInstanceOf[OrderingConstraint]
541535
new OrderingConstraint(

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,6 @@ object Phases {
385385
override def toString = phaseName
386386
}
387387

388-
trait NeedsCompanions {
389-
def isCompanionNeeded(cls: ClassSymbol)(implicit ctx: Context): Boolean
390-
}
391-
392388
/** Replace all instances of `oldPhaseClass` in `current` phases
393389
* by the result of `newPhases` applied to the old phase.
394390
*/

compiler/src/dotty/tools/dotc/core/Signature.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ case class Signature(paramsSig: List[TypeName], resSig: TypeName) {
4545
final def consistentParams(that: Signature): Boolean = {
4646
@tailrec def loop(names1: List[TypeName], names2: List[TypeName]): Boolean =
4747
if (names1.isEmpty) names2.isEmpty
48-
else names2.nonEmpty && consistent(names1.head, names2.head) && loop(names1.tail, names2.tail)
48+
else !names2.isEmpty && consistent(names1.head, names2.head) && loop(names1.tail, names2.tail)
4949
loop(this.paramsSig, that.paramsSig)
5050
}
5151

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,15 +2862,16 @@ object Types {
28622862

28632863
type This = MethodType
28642864

2865+
val paramInfos = paramInfosExp(this)
2866+
val resType = resultTypeExp(this)
2867+
assert(resType.exists)
2868+
28652869
def companion: MethodTypeCompanion
28662870

28672871
final override def isJavaMethod: Boolean = companion eq JavaMethodType
28682872
final override def isImplicitMethod: Boolean = companion.eq(ImplicitMethodType) || companion.eq(ErasedImplicitMethodType)
28692873
final override def isErasedMethod: Boolean = companion.eq(ErasedMethodType) || companion.eq(ErasedImplicitMethodType)
28702874

2871-
val paramInfos = paramInfosExp(this)
2872-
val resType = resultTypeExp(this)
2873-
assert(resType.exists)
28742875

28752876
def computeSignature(implicit ctx: Context): Signature = {
28762877
val params = if (isErasedMethod) Nil else paramInfos

0 commit comments

Comments
 (0)