Skip to content

Commit 07e24e8

Browse files
committed
Merge pull request #735 from dotty-staging/ycheck-methods
Ycheck that methods defined in ClassInfo exist in tree.
2 parents 056e124 + d528035 commit 07e24e8

File tree

117 files changed

+137
-48
lines changed

Some content is hidden

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

117 files changed

+137
-48
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object DottyBuild extends Build {
4242
resolvers += Resolver.sonatypeRepo("releases"),
4343

4444
// get libraries onboard
45-
partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150619-173733-3bcd390afa",
45+
partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150714-145300-2ad68448c5",
4646
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
4747
"org.scala-lang" % "scala-library" % scalaVersion.value % "test"),
4848
libraryDependencies ++= partestDeps.value,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
784784
def decls: List[Symbol] = tp.decls.map(_.symbol).toList
785785

786786
def members: List[Symbol] =
787-
tp.memberDenots(takeAllFilter, (name, buf) => buf ++= member(name).alternatives).map(_.symbol).toList
787+
tp.memberDenots(takeAllFilter, (name, buf) => buf ++= tp.member(name).alternatives).map(_.symbol).toList
788788

789789
def typeSymbol: Symbol = tp.widenDealias.typeSymbol
790790

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ object Trees {
223223

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

226-
override def hashCode(): Int = System.identityHashCode(this)
226+
override def hashCode(): Int = uniqueId // for debugging; was: System.identityHashCode(this)
227227
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
228228
}
229229

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,26 @@ object Contexts {
177177
/** The new implicit references that are introduced by this scope */
178178
private var implicitsCache: ContextualImplicits = null
179179
def implicits: ContextualImplicits = {
180-
if (implicitsCache == null )
181-
implicitsCache = {
182-
val implicitRefs: List[TermRef] =
183-
if (isClassDefContext)
184-
try owner.thisType.implicitMembers
185-
catch {
186-
case ex: CyclicReference => Nil
187-
}
188-
else if (isImportContext) importInfo.importedImplicits
189-
else if (isNonEmptyScopeContext) scope.implicitDecls
190-
else Nil
191-
val outerImplicits =
192-
if (isImportContext && importInfo.hiddenRoot.exists)
193-
outer.implicits exclude importInfo.hiddenRoot
194-
else
195-
outer.implicits
196-
if (implicitRefs.isEmpty) outerImplicits
197-
else new ContextualImplicits(implicitRefs, outerImplicits)(this)
180+
if (implicitsCache == null ) {
181+
val outerImplicits =
182+
if (isImportContext && importInfo.hiddenRoot.exists)
183+
outer.implicits exclude importInfo.hiddenRoot
184+
else
185+
outer.implicits
186+
try
187+
implicitsCache = {
188+
val implicitRefs: List[TermRef] =
189+
if (isClassDefContext) owner.thisType.implicitMembers
190+
else if (isImportContext) importInfo.importedImplicits
191+
else if (isNonEmptyScopeContext) scope.implicitDecls
192+
else Nil
193+
if (implicitRefs.isEmpty) outerImplicits
194+
else new ContextualImplicits(implicitRefs, outerImplicits)(this)
195+
}
196+
catch {
197+
case ex: CyclicReference => implicitsCache = outerImplicits
198198
}
199+
}
199200
implicitsCache
200201
}
201202

src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ object NameOps {
241241
case nme.clone_ => nme.clone_
242242
}
243243

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

246246
def typeToTag(tp: Types.Type): Name = {
247247
tp.classSymbol match {
@@ -258,9 +258,12 @@ object NameOps {
258258
}
259259
}
260260

261+
val methodTags: Seq[Name] = (methodTargs zip methodTarsNames).sortBy(_._2).map(x => typeToTag(x._1))
262+
val classTags: Seq[Name] = (classTargs zip classTargsNames).sortBy(_._2).map(x => typeToTag(x._1))
263+
261264
name.fromName(name ++ nme.specializedTypeNames.prefix ++
262-
args.map(typeToTag).foldRight(typeToTag(returnType))(_ ++ _) ++
263-
nme.specializedTypeNames.suffix)
265+
methodTags.fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.separator ++
266+
classTags.fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.suffix)
264267
}
265268

266269
/** If name length exceeds allowable limit, replace part of it by hash */

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,25 @@ object Names {
348348
StringBuilder.newBuilder.mapResult(s => from.fromChars(s.toCharArray, 0, s.length))
349349
def apply(): Builder[Char, Name] = termNameBuilder
350350
}
351+
352+
implicit val NameOrdering: Ordering[Name] = new Ordering[Name] {
353+
def compare(x: Name, y: Name): Int = {
354+
if (x.isTermName && y.isTypeName) 1
355+
else if (x.isTypeName && y.isTermName) -1
356+
else if (x eq y) 0
357+
else {
358+
val until = x.length min y.length
359+
var i = 0
360+
361+
while (i < until && x(i) == y(i)) i = i + 1
362+
363+
if (i < until) {
364+
if (x(i) < y(i)) -1
365+
else /*(x(i) > y(i))*/ 1
366+
} else {
367+
x.length - y.length
368+
}
369+
}
370+
}
371+
}
351372
}

src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ object StdNames {
559559
final val Void: N = "V"
560560
final val Object: N = "L"
561561

562-
final val prefix: N = "$mc"
562+
final val prefix: N = "$m"
563+
final val separator: N = "c"
563564
final val suffix: N = "$sp"
564565
}
565566

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ object SymDenotations {
404404
name.toTermName == nme.COMPANION_CLASS_METHOD ||
405405
name.toTermName == nme.COMPANION_MODULE_METHOD
406406

407+
/** Is this a syntetic method that represents conversions between representations of a value class
408+
* These methods are generated in ExtensionMethods
409+
* and used in ElimErasedValueType.
410+
*/
411+
final def isValueClassConvertMethod(implicit ctx: Context) =
412+
name.toTermName == nme.U2EVT ||
413+
name.toTermName == nme.EVT2U
414+
407415
/** Is symbol a primitive value class? */
408416
def isPrimitiveValueClass(implicit ctx: Context) = defn.ScalaValueClasses contains symbol
409417

src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ object Symbols {
503503
def showKind(implicit ctx: Context): String = ctx.kindString(this)
504504
def showName(implicit ctx: Context): String = ctx.nameString(this)
505505
def showFullName(implicit ctx: Context): String = ctx.fullNameString(this)
506+
507+
override def hashCode() = id // for debugging.
506508
}
507509

508510
type TermSymbol = Symbol { type ThisName = TermName }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ object Types {
12961296
case d: SymDenotation =>
12971297
if (this.isInstanceOf[WithFixedSym]) d.current
12981298
else if (d.validFor.runId == ctx.runId || ctx.stillValid(d))
1299-
if (prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
1299+
if (d.exists && prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
13001300
else recomputeMember(d) // symbol could have been overridden, recompute membership
13011301
else {
13021302
val newd = loadDenot

0 commit comments

Comments
 (0)