aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala6
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala2
-rw-r--r--src/dotty/tools/dotc/config/ScalaSettings.scala4
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala6
-rw-r--r--src/dotty/tools/dotc/core/Names.scala2
-rw-r--r--src/dotty/tools/dotc/core/Phases.scala3
-rw-r--r--src/dotty/tools/dotc/core/StdNames.scala3
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala3
-rw-r--r--src/dotty/tools/dotc/core/Types.scala13
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala4
-rw-r--r--src/dotty/tools/dotc/transform/LambdaLift.scala10
-rw-r--r--src/dotty/tools/dotc/transform/MixinOps.scala7
-rw-r--r--src/dotty/tools/dotc/transform/SymUtils.scala29
13 files changed, 71 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index c414de130..943b54d7f 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -14,6 +14,9 @@ import dotty.tools.dotc.transform.TreeTransforms.{TreeTransform, TreeTransformer
import dotty.tools.dotc.core.DenotTransformers.DenotTransformer
import dotty.tools.dotc.core.Denotations.SingleDenotation
+
+import dotty.tools.backend.jvm.{LabelDefs, GenBCode}
+
class Compiler {
/** Meta-ordering constraint:
@@ -61,7 +64,8 @@ class Compiler {
List(new LambdaLift,
new Flatten,
new RestoreScopes),
- List(new PrivateToStatic)
+ List(/*new PrivateToStatic,*/ new CollectEntryPoints, new LabelDefs),
+ List(new GenBCode)
)
var runId = 1
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 462c223fb..8fdc4a9db 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -361,7 +361,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val constrSym = modcls.primaryConstructor orElse ctx.newDefaultConstructor(modcls).entered
val constr = DefDef(constrSym.asTerm, EmptyTree)
val clsdef = ClassDef(modcls, constr, body)
- val valdef = ValDef(sym, New(modcls.typeRef))
+ val valdef = ValDef(sym, New(modcls.typeRef).select(constrSym).appliedToNone)
Thicket(valdef, clsdef)
}
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala
index 9afe96c96..35c3ac16a 100644
--- a/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -26,8 +26,8 @@ class ScalaSettings extends Settings.SettingGroup {
val nowarn = BooleanSetting("-nowarn", "Generate no warnings.")
val print = BooleanSetting("-print", "Print program with Scala-specific features removed.")
val target = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.",
- List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "msil"),
- "jvm-1.6")
+ List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "jvm-1.8", "msil"),
+ "jvm-1.8")
val unchecked = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.")
val uniqid = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.")
val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.")
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 19d175088..a7c7ac3c6 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -269,11 +269,11 @@ class Definitions {
// fundamental classes
lazy val StringClass = ctx.requiredClass("java.lang.String")
- lazy val StringModule = StringClass.moduleClass
+ lazy val StringModule = StringClass.linkedClass
lazy val String_+ = newMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final)
lazy val String_valueOf_Object = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
- case List(pt) => pt isRef ObjectClass
+ case List(pt) => (pt isRef AnyClass) || (pt isRef ObjectClass)
case _ => false
}).symbol
@@ -398,7 +398,7 @@ class Definitions {
def apply(elem: Type)(implicit ctx: Context) =
if (ctx.erasedTypes) JavaArrayType(elem)
else ArrayClass.typeRef.appliedTo(elem :: Nil)
- def unapply(tp: Type)(implicit ctx: Context) = tp.dealias match {
+ def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealias match {
case at: RefinedType if (at isRef ArrayClass) && at.argInfos.length == 1 => Some(at.argInfos.head)
case _ => None
}
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index cf53d0445..f0d3f02eb 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -200,7 +200,7 @@ object Names {
private final val fillFactor = 0.7
/** Memory to store all names sequentially. */
- private var chrs: Array[Char] = new Array[Char](InitialNameSize)
+ private[dotty] var chrs: Array[Char] = new Array[Char](InitialNameSize)
/** The number of characters filled. */
private var nc = 0
diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala
index 5777c0f5b..70dd4296a 100644
--- a/src/dotty/tools/dotc/core/Phases.scala
+++ b/src/dotty/tools/dotc/core/Phases.scala
@@ -3,6 +3,7 @@ package core
import Periods._
import Contexts._
+import dotty.tools.backend.jvm.GenBCode
import util.DotClass
import DenotTransformers._
import Denotations._
@@ -171,6 +172,7 @@ object Phases {
private val flattenCache = new PhaseCache(classOf[Flatten])
private val explicitOuterCache = new PhaseCache(classOf[ExplicitOuter])
private val gettersCache = new PhaseCache(classOf[Getters])
+ private val genBCodeCache = new PhaseCache(classOf[GenBCode])
def typerPhase = typerCache.phase
def refchecksPhase = refChecksCache.phase
@@ -179,6 +181,7 @@ object Phases {
def flattenPhase = flattenCache.phase
def explicitOuterPhase = explicitOuterCache.phase
def gettersPhase = gettersCache.phase
+ def genBCodePhase = genBCodeCache.phase
def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id
}
diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala
index 24e948fa9..04bcf616d 100644
--- a/src/dotty/tools/dotc/core/StdNames.scala
+++ b/src/dotty/tools/dotc/core/StdNames.scala
@@ -510,6 +510,9 @@ object StdNames {
val wrap: N = "wrap"
val zero: N = "zero"
val zip: N = "zip"
+ val nothingRuntimeClass: N = "scala.runtime.Nothing$"
+ val nullRuntimeClass: N = "scala.runtime.Null$"
+
val synthSwitch: N = "$synthSwitch"
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index a05296802..eccdcbfb9 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -324,6 +324,9 @@ object SymDenotations {
final def isAnonymousClass(implicit ctx: Context): Boolean =
isClass && (initial.asSymDenotation.name startsWith tpnme.ANON_CLASS)
+ final def isAnonymousFunction(implicit ctx: Context) =
+ this.symbol.is(Method) && (initial.asSymDenotation.name startsWith nme.ANON_FUN)
+
/** Is symbol a primitive value class? */
def isPrimitiveValueClass(implicit ctx: Context) = defn.ScalaValueClasses contains symbol
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 473b23f7b..a1ca7796f 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -29,6 +29,7 @@ import collection.{mutable, Seq, breakOut}
import config.Config
import config.Printers._
import annotation.tailrec
+import Flags.FlagSet
import language.implicitConversions
object Types {
@@ -523,6 +524,18 @@ object Types {
.toList.map(d => TermRef.withSig(this, d.symbol.asTerm))
}
+ /** The set of member classes of this type */
+ final def memberClasses(implicit ctx: Context): Seq[SingleDenotation] = track("implicitMembers") {
+ memberDenots(typeNameFilter,
+ (name, buf) => buf ++= member(name).altsWith(x => x.isClass))
+ }
+
+ /** The set of members of this type having at least one of `requiredFlags` but none of `excludedFlags` set */
+ final def membersBasedOnFlags(requiredFlags: FlagSet, excludedFlags: FlagSet)(implicit ctx: Context): Seq[SingleDenotation] = track("implicitMembers") {
+ memberDenots(takeAllFilter,
+ (name, buf) => buf ++= member(name).altsWith(x => x.is(requiredFlags, butNot = excludedFlags)))
+ }
+
/** The info of `sym`, seen as a member of this type. */
final def memberInfo(sym: Symbol)(implicit ctx: Context): Type =
sym.info.asSeenFrom(this, sym.owner)
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 8231c25af..cc3d3eb7f 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -876,7 +876,9 @@ class ClassfileParser(
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
- if (name.isModuleClassName) c = ctx.requiredModule(name.sourceModuleName)
+ if (name.isModuleClassName && (name ne nme.nothingRuntimeClass) && (name ne nme.nullRuntimeClass))
+ // Null$ and Nothing$ ARE classes
+ c = ctx.requiredModule(name.sourceModuleName)
else c = classNameToSymbol(name)
values(index) = c
}
diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala
index 95c5cd529..c8dacd1d7 100644
--- a/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -257,8 +257,8 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
case mt @ MethodType(pnames, ptypes) =>
val ps = proxies(local.skipConstructor)
MethodType(
- pnames ++ ps.map(_.name.asTermName),
- ptypes ++ ps.map(_.info),
+ ps.map(_.name.asTermName) ++ pnames,
+ ps.map(_.info) ++ ptypes,
mt.resultType)
case info => info
}
@@ -340,7 +340,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
private def addFreeArgs(sym: Symbol, args: List[Tree])(implicit ctx: Context, info: TransformerInfo) =
free get sym match {
- case Some(fvs) => args ++ fvs.toList.map(proxyRef(_))
+ case Some(fvs) => fvs.toList.map(proxyRef(_)) ++ args
case _ => args
}
@@ -354,9 +354,9 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
transformFollowingDeep(ValDef(proxy.asTerm).withPos(tree.pos)).asInstanceOf[ValDef])
tree match {
case tree: DefDef =>
- cpy.DefDef(tree)(vparamss = tree.vparamss.map(_ ++ freeParamDefs))
+ cpy.DefDef(tree)(vparamss = tree.vparamss.map(freeParamDefs ++ _))
case tree: Template =>
- cpy.Template(tree)(body = tree.body ++ freeParamDefs)
+ cpy.Template(tree)(body = freeParamDefs ++ tree.body)
}
}
diff --git a/src/dotty/tools/dotc/transform/MixinOps.scala b/src/dotty/tools/dotc/transform/MixinOps.scala
index de15b045f..e6074323a 100644
--- a/src/dotty/tools/dotc/transform/MixinOps.scala
+++ b/src/dotty/tools/dotc/transform/MixinOps.scala
@@ -4,15 +4,14 @@ package transform
import core._
import Symbols._, Types._, Contexts._, SymDenotations._, DenotTransformers._, Flags._
import util.Positions._
+import SymUtils._
import StdNames._, NameOps._
class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx: Context) {
import ast.tpd._
- val superCls: Symbol = cls.classInfo.parents.head.symbol
- val mixins: List[ClassSymbol] =
- if (cls is Trait) Nil
- else cls.baseClasses.tail.takeWhile(_ ne superCls).reverse
+ val superCls: Symbol = cls.superClass
+ val mixins: List[ClassSymbol] = cls.mixins
def implementation(member: TermSymbol): TermSymbol =
member.copy(
diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala
index 7d485f64c..9274150b1 100644
--- a/src/dotty/tools/dotc/transform/SymUtils.scala
+++ b/src/dotty/tools/dotc/transform/SymUtils.scala
@@ -24,6 +24,32 @@ object SymUtils {
class SymUtils(val self: Symbol) extends AnyVal {
import SymUtils._
+ def superClass(implicit ctx: Context) = {
+ val parents = self.asClass.classInfo.parents
+ if (parents.isEmpty) NoSymbol
+ else parents.head.symbol
+ }
+
+
+ /**
+ * For a class: All interfaces implemented by a class except for those inherited through the superclass.
+ * For a trait: all parent traits
+ */
+
+ def superInterfaces(implicit ctx: Context) = {
+ val superCls = self.superClass
+ val baseClasses = self.asClass.baseClasses
+ if (baseClasses.isEmpty) Nil
+ else baseClasses.tail.takeWhile(_ ne superCls).reverse
+
+ }
+
+ /** All interfaces implemented by a class, except for those inherited through the superclass. */
+ def mixins(implicit ctx: Context) = {
+ if (self is Trait) Nil
+ else superInterfaces
+ }
+
def isTypeTestOrCast(implicit ctx: Context): Boolean =
self == defn.Any_asInstanceOf || self == defn.Any_isInstanceOf
@@ -36,9 +62,6 @@ class SymUtils(val self: Symbol) extends AnyVal {
final def skipConstructor(implicit ctx: Context): Symbol =
if (self.isConstructor) self.owner else self
- final def isAnonymousFunction(implicit ctx: Context): Boolean =
- self.is(Method) && (self.denot.initial.asSymDenotation.name startsWith nme.ANON_FUN)
-
/** The logically enclosing method or class for this symbol.
* Instead of constructors one always picks the enclosing class.
*/