aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-21 14:52:04 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-11 08:24:36 +0200
commit330773619d01b9f684676ec4253b3d76c4807222 (patch)
tree3dd54e60e343744348aa28dfffc70397cf70399d /src/dotty/tools/dotc/core
parent3f542aabf7944cc36302753d6126bb06e571d218 (diff)
downloaddotty-330773619d01b9f684676ec4253b3d76c4807222.tar.gz
dotty-330773619d01b9f684676ec4253b3d76c4807222.tar.bz2
dotty-330773619d01b9f684676ec4253b3d76c4807222.zip
Fix to primaryConstructor
Primary constructor was picking last constructor instead of first one. This is now fixed. Also, added paramAccessors utility method.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala2
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala5
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala8
3 files changed, 12 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 6b9b1dec7..3b14872b7 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -282,7 +282,7 @@ object Contexts {
* from constructor parameters to class paramater accessors.
*/
def superCallContext: Context = {
- val locals = newScopeWith(owner.decls.filter(_ is ParamAccessor).toList: _*)
+ val locals = newScopeWith(owner.asClass.paramAccessors: _*)
superOrThisCallContext(owner.primaryConstructor, locals)
}
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 09b67d08a..82fd60fa0 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -681,6 +681,7 @@ object Denotations {
// ------ PreDenotation ops ----------------------------------------------
final def first = this
+ final def last = this
final def toDenot(pre: Type)(implicit ctx: Context): Denotation = this
final def containsSym(sym: Symbol): Boolean = hasUniqueSym && (symbol eq sym)
final def containsSig(sig: Signature)(implicit ctx: Context) =
@@ -766,8 +767,9 @@ object Denotations {
/** A denotation in the group exists */
def exists: Boolean
- /** First denotation in the group */
+ /** First/last denotation in the group */
def first: Denotation
+ def last: Denotation
/** Convert to full denotation by &-ing all elements */
def toDenot(pre: Type)(implicit ctx: Context): Denotation
@@ -832,6 +834,7 @@ object Denotations {
assert(denots1.exists && denots2.exists, s"Union of non-existing denotations ($denots1) and ($denots2)")
def exists = true
def first = denots1.first
+ def last = denots2.last
def toDenot(pre: Type)(implicit ctx: Context) =
(denots1 toDenot pre) & (denots2 toDenot pre, pre)
def containsSym(sym: Symbol) =
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index ed123a384..378d95b81 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -1423,9 +1423,15 @@ object SymDenotations {
override def primaryConstructor(implicit ctx: Context): Symbol = {
val cname = if (this is ImplClass) nme.IMPLCLASS_CONSTRUCTOR else nme.CONSTRUCTOR
- decls.denotsNamed(cname).first.symbol
+ decls.denotsNamed(cname).last.symbol // denotsNamed returns Symbols in reverse order of occurrence
}
+ /** The parameter accessors of this class. Term and type accessors,
+ * getters and setters are all returned int his list
+ */
+ def paramAccessors(implicit ctx: Context): List[Symbol] =
+ decls.filter(_ is ParamAccessor).toList
+
/** If this class has the same `decls` scope reference in `phase` and
* `phase.next`, install a new denotation with a cloned scope in `phase.next`.
*/