aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-05-06 19:27:44 +0200
committerMartin Odersky <odersky@gmail.com>2016-05-23 16:11:45 +0200
commita88de62e5d60fe8ba83d99bd463797e6b173e3d1 (patch)
treeac00eace9d22fde844eab1931cdb1896d35e36ff /src/dotty/tools
parentec71e006ea5d506b55ba624999b0d2aa01b2d7c1 (diff)
downloaddotty-a88de62e5d60fe8ba83d99bd463797e6b173e3d1.tar.gz
dotty-a88de62e5d60fe8ba83d99bd463797e6b173e3d1.tar.bz2
dotty-a88de62e5d60fe8ba83d99bd463797e6b173e3d1.zip
Safe equality for core classes:
Name, Symbol, Denotation, Type. This uncovered two nonsensical comparisons, one in CollectEntryPoints, the other in DottyBackendInterface.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala10
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/Names.scala2
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala2
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
-rw-r--r--src/dotty/tools/dotc/transform/CollectEntryPoints.scala2
6 files changed, 14 insertions, 6 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index a64ce5900..002a6bf27 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -861,11 +861,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context
"If possible, please file a bug on issues.scala-lang.org.")
tp match {
- case ThisType(ArrayClass) => ObjectReference.asInstanceOf[ct.bTypes.ClassBType] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
- case ThisType(sym) => storage.getClassBTypeAndRegisterInnerClass(sym.asInstanceOf[ct.int.Symbol])
- // case t: SingletonType => primitiveOrClassToBType(t.classSymbol)
- case t: SingletonType => t.underlying.toTypeKind(ct)(storage)
- case t: RefinedType => t.parent.toTypeKind(ct)(storage) //parents.map(_.toTypeKind(ct)(storage).asClassBType).reduceLeft((a, b) => a.jvmWiseLUB(b))
+ case tp: ThisType if tp.cls == ArrayClass => ObjectReference.asInstanceOf[ct.bTypes.ClassBType] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
+ case tp: ThisType => storage.getClassBTypeAndRegisterInnerClass(tp.cls.asInstanceOf[ct.int.Symbol])
+ // case t: SingletonType => primitiveOrClassToBType(t.classSymbol)
+ case t: SingletonType => t.underlying.toTypeKind(ct)(storage)
+ case t: RefinedType => t.parent.toTypeKind(ct)(storage) //parents.map(_.toTypeKind(ct)(storage).asClassBType).reduceLeft((a, b) => a.jvmWiseLUB(b))
}
}
}
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 080e8a39b..69624b01a 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -70,6 +70,8 @@ import Decorators.SymbolIteratorDecorator
*/
object Denotations {
+ implicit def eqDenotation: Eq[Denotation, Denotation] = Eq
+
/** A denotation is the result of resolving
* a name (either simple identifier or select) during a given period.
*
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index 10eef16c1..223d95045 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -26,6 +26,8 @@ object Names {
def toTermName: TermName
}
+ implicit def eqName: Eq[Name, Name] = Eq
+
/** A name is essentially a string, with three differences
* 1. Names belong in one of two name spaces: they are type names or term names.
* Term names have a sub-category of "local" field names.
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index d40acdfa7..473f107cb 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -361,6 +361,8 @@ trait Symbols { this: Context =>
object Symbols {
+ implicit def eqSymbol: Eq[Symbol, Symbol] = Eq
+
/** A Symbol represents a Scala definition/declaration or a package.
* @param coord The coordinates of the symbol (a position or an index)
* @param id A unique identifier of the symbol (unique per ContextBase)
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 114e6c908..71ea6d2b3 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -38,6 +38,8 @@ object Types {
@sharable private var nextId = 0
+ implicit def eqType: Eq[Type, Type] = Eq
+
/** The class of types.
* The principal subclasses and sub-objects are as follows:
*
diff --git a/src/dotty/tools/dotc/transform/CollectEntryPoints.scala b/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
index b85c44647..714255962 100644
--- a/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
+++ b/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
@@ -75,7 +75,7 @@ class CollectEntryPoints extends MiniPhaseTransform {
val javaPlatform = ctx.platform.asInstanceOf[JavaPlatform]
if (javaPlatform.hasJavaMainMethod(companion))
failNoForwarder("companion contains its own main method")
- else if (companion != NoSymbol && companion.info.member(nme.main) != NoSymbol)
+ else if (companion.exists && companion.info.member(nme.main).exists)
// this is only because forwarders aren't smart enough yet
failNoForwarder("companion contains its own main method (implementation restriction: no main is allowed, regardless of signature)")
else if (companion.flags is Flags.Trait)