Skip to content
Merged
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object DottyBuild extends Build {
resolvers += Resolver.sonatypeRepo("releases"),

// get libraries onboard
partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150619-173733-3bcd390afa",
partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150714-145300-2ad68448c5",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-library" % scalaVersion.value % "test"),
libraryDependencies ++= partestDeps.value,
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ object Trees {

override def toText(printer: Printer) = printer.toText(this)

override def hashCode(): Int = System.identityHashCode(this)
override def hashCode(): Int = uniqueId
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
}

Expand Down
9 changes: 6 additions & 3 deletions src/dotty/tools/dotc/core/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ object NameOps {
case nme.clone_ => nme.clone_
}

def specializedFor(returnType: Types.Type, args: List[Types.Type])(implicit ctx: Context): name.ThisName = {
def specializedFor(classTargs: List[Types.Type], classTargsNames: List[Name], methodTargs: List[Types.Type], methodTarsNames: List[Name])(implicit ctx: Context): name.ThisName = {

def typeToTag(tp: Types.Type): Name = {
tp.classSymbol match {
Expand All @@ -253,9 +253,12 @@ object NameOps {
}
}

val methodTags: Seq[Name] = (methodTargs zip methodTarsNames).sortBy(_._2).map(x => typeToTag(x._1))
val classTags: Seq[Name] = (classTargs zip classTargsNames).sortBy(_._2).map(x => typeToTag(x._1))

name.fromName(name ++ nme.specializedTypeNames.prefix ++
args.map(typeToTag).foldRight(typeToTag(returnType))(_ ++ _) ++
nme.specializedTypeNames.suffix)
methodTags.fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.separator ++
classTags.fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.suffix)
}

/** If name length exceeds allowable limit, replace part of it by hash */
Expand Down
21 changes: 21 additions & 0 deletions src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,25 @@ object Names {
StringBuilder.newBuilder.mapResult(s => from.fromChars(s.toCharArray, 0, s.length))
def apply(): Builder[Char, Name] = termNameBuilder
}

implicit val NameOrdering: Ordering[Name] = new Ordering[Name] {
def compare(x: Name, y: Name): Int = {
if (x.isTermName && y.isTypeName) 1
else if (x.isTypeName && y.isTermName) -1
else if (x eq y) 0
else {
val until = x.length min y.length
var i = 0

while (i < until && x(i) == y(i)) i = i + 1

if (i < until) {
if (x(i) < y(i)) -1
else /*(x(i) > y(i))*/ 1
} else {
x.length - y.length
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ object StdNames {
final val Void: N = "V"
final val Object: N = "L"

final val prefix: N = "$mc"
final val prefix: N = "$m"
final val separator: N = "c"
final val suffix: N = "$sp"
}

Expand Down
2 changes: 2 additions & 0 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ object Symbols {
def showKind(implicit ctx: Context): String = ctx.kindString(this)
def showName(implicit ctx: Context): String = ctx.nameString(this)
def showFullName(implicit ctx: Context): String = ctx.fullNameString(this)

override def hashCode() = id
}

type TermSymbol = Symbol { type ThisName = TermName }
Expand Down
7 changes: 6 additions & 1 deletion src/dotty/tools/dotc/transform/FunctionalInterfaces.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ class FunctionalInterfaces extends MiniPhaseTransform {
val m = tree.meth.tpe.widen.asInstanceOf[MethodType]

if (shouldSpecialize(m)) {
val interfaceName = (functionName ++ m.paramTypes.length.toString).specializedFor(m.resultType, m.paramTypes)
val functionSymbol = tree.tpe.widenDealias.classSymbol
val names = ctx.atPhase(ctx.erasurePhase) {
implicit ctx => functionSymbol.typeParams.map(_.name)
}
val interfaceName = (functionName ++ m.paramTypes.length.toString).specializedFor(m.paramTypes ::: m.resultType :: Nil, names, Nil, Nil)

// symbols loaded from classpath aren't defined in periods earlier than when they where loaded
val interface = ctx.withPhase(ctx.typerPhase).getClassIfDefined(functionPackage ++ interfaceName)
if (interface.exists) {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
// require (nbSubPats > 0 && (!lastIsStar || isSeq))
protected def subPatRefs(binder: Symbol): List[Tree] = {
val refs = if (totalArity > 0 && isSeq) subPatRefsSeq(binder)
else if (totalArity > 1 && !isSeq) productElemsToN(binder, totalArity)
else if (binder.info.member(nme._1).exists && !isSeq) productElemsToN(binder, totalArity)
else ref(binder):: Nil
refs
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
exceptions-2.scala:267: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
try { 1 } catch { case e: java.io.IOException => () }
^
nested1:
Innermost finally
Outermost finally
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/run/value-class-extractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object NonNullChar {
@inline final val None = new NonNullChar(0.toChar)
}

final class SomeProduct /*extends Product3[String, Int, List[String]]*/ {
final class SomeProduct extends Product3[String, Int, List[String]] {
def canEqual(x: Any) = x.isInstanceOf[SomeProduct]
def _1 = "abc"
def _2 = 5
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.