Skip to content

Fix jvm8 lamba related issues. #483

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 6 commits into from
Apr 16, 2015
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
10 changes: 5 additions & 5 deletions bin/dotc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Configuration
SCALA_VERSION=2.11.5
SCALA_BINARY_VERSION=2.11
SCALA_COMPILER_VERSION=2.11.5-20150402-193021-0c75410da3
SCALA_COMPILER_VERSION=2.11.5-20150416-144435-09c4a520e1
DOTTY_VERSION=0.1
JLINE_VERSION=2.12
bootcp=true
Expand Down Expand Up @@ -57,13 +57,13 @@ checkjar $TEST_JAR test:package

# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
if [ "$SCALA_LIBRARY_JAR" == "" ]
then
then
SCALA_LIBRARY_JAR=$HOME/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-$SCALA_VERSION.jar
# this is location where sbt stores it in ivy cache
fi
# save as for scala-library now for scala-reflect
if [ "$SCALA_REFLECT_JAR" == "" ]
then
then
SCALA_REFLECT_JAR=$HOME/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-$SCALA_VERSION.jar
fi
if [ "$SCALA_COMPILER_JAR" == "" ]
Expand All @@ -72,13 +72,13 @@ then
fi

if [ "$JLINE_JAR" == "" ]
then
then
JLINE_JAR=$HOME/.ivy2//cache/jline/jline/jars/jline-$JLINE_VERSION.jar
fi

if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_COMPILER_JAR" -o ! -f "$JLINE_JAR" ]
then
echo To use this script please set
echo To use this script please set
echo SCALA_LIBRARY_JAR to point to scala-library-$SCALA_VERSION.jar "(currently $SCALA_LIBRARY_JAR)"
echo SCALA_REFLECT_JAR to point to scala-reflect-$SCALA_VERSION.jar "(currently $SCALA_REFLECT_JAR)"
echo SCALA_COMPILER_JAR to point to scala-compiler-$SCALA_VERSION.jar with bcode patches "(currently $SCALA_COMPILER_JAR)"
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object DottyBuild extends Build {
// get reflect and xml onboard
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"me.d-d" % "scala-compiler" % "2.11.5-20150402-193021-0c75410da3",
"me.d-d" % "scala-compiler" % "2.11.5-20150416-144435-09c4a520e1",
"jline" % "jline" % "2.12"),

// get junit onboard
Expand Down
37 changes: 31 additions & 6 deletions src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
type Alternative = tpd.Alternative
type DefDef = tpd.DefDef
type Template = tpd.Template
type Select = tpd.Select
type Select = tpd.Tree // Actually tpd.Select || tpd.Ident
type Bind = tpd.Bind
type New = tpd.New
type Super = tpd.Super
Expand Down Expand Up @@ -103,6 +103,10 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
val BoxesRunTimeModule = ctx.requiredModule("scala.runtime.BoxesRunTime")
val BoxesRunTimeClass = toDenot(BoxesRunTimeModule).moduleClass.asClass

// require LambdaMetafactory: scalac uses getClassIfDefined, but we need those always.
override lazy val LambdaMetaFactory = ctx.requiredClass("java.lang.invoke.LambdaMetafactory")
override lazy val MethodHandle = ctx.requiredClass("java.lang.invoke.MethodHandle")

val nme_valueOf: Name = StdNames.nme.valueOf
val nme_apply = StdNames.nme.apply
val NothingClass: Symbol = defn.NothingClass
Expand Down Expand Up @@ -243,7 +247,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
}
case t: TypeApply if (t.fun.symbol == Predef_classOf) =>
av.visit(name, t.args.head.tpe.classSymbol.denot.info.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
case t: Select =>
case t: tpd.Select =>
if (t.symbol.denot.is(Flags.Enum)) {
val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the enumeration class.
val evalue = t.symbol.name.toString // value the actual enumeration value.
Expand Down Expand Up @@ -416,14 +420,14 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{


def isQualifierSafeToElide(qual: Tree): Boolean = tpd.isIdempotentExpr(qual)
def desugarIdent(i: Ident): Option[Select] = {
def desugarIdent(i: Ident): Option[tpd.Select] = {
i.tpe match {
case TermRef(prefix: TermRef, name) =>
Some(tpd.ref(prefix).select(i.symbol))
case TermRef(prefix: ThisType, name) =>
Some(tpd.This(prefix.cls).select(i.symbol))
case TermRef(NoPrefix, name) =>
if (i.symbol is Flags.Method) Some(This(i.symbol.enclosingClass).select(i.symbol)) // workaround #342 todo: remove after fixed
if (i.symbol is Flags.Method) Some(This(i.symbol.topLevelClass).select(i.symbol)) // workaround #342 todo: remove after fixed
else None
case _ => None
}
Expand Down Expand Up @@ -857,8 +861,29 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
}

object Select extends SelectDeconstructor {
def _1: Tree = field.qualifier
def _2: Name = field.name

var desugared: tpd.Select = null

override def isEmpty: Boolean =
desugared eq null

def _1: Tree = desugared.qualifier

def _2: Name = desugared.name

override def unapply(s: Select): this.type = {
s match {
case t: tpd.Select => desugared = t
case t: Ident =>
desugarIdent(t) match {
case Some(t) => desugared = t
case None => desugared = null
}
case _ => desugared = null
}

this
}
}

object Apply extends ApplyDeconstructor {
Expand Down