summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-11-02 00:14:26 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-11-02 00:14:26 +0000
commit3f26904e68a2693b57f5b08eac1847676ff748d2 (patch)
treeaf934de5b5e373440b041d9c5333cd46c8951e89
parentae4910485511c12cda0c110b6563610041070b5d (diff)
downloadscala-3f26904e68a2693b57f5b08eac1847676ff748d2.tar.gz
scala-3f26904e68a2693b57f5b08eac1847676ff748d2.tar.bz2
scala-3f26904e68a2693b57f5b08eac1847676ff748d2.zip
Closes #2792. no review
-rw-r--r--src/compiler/scala/tools/nsc/dependencies/Changes.scala15
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala10
-rw-r--r--test/files/buildmanager/t2792/A1.scala3
-rw-r--r--test/files/buildmanager/t2792/A2.scala4
-rw-r--r--test/files/buildmanager/t2792/A3.scala3
-rw-r--r--test/files/buildmanager/t2792/t2792.changes/A1_1.scala3
-rw-r--r--test/files/buildmanager/t2792/t2792.check11
-rw-r--r--test/files/buildmanager/t2792/t2792.test3
8 files changed, 44 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala
index 6aef637902..9794d71db1 100644
--- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala
+++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala
@@ -24,8 +24,11 @@ abstract class Changes {
/** Are the new modifiers more restrictive than the old ones? */
private def moreRestrictive(from: Long, to: Long): Boolean =
((((to & PRIVATE) != 0L) && (from & PRIVATE) == 0L)
- || (((to & PROTECTED) != 0L) && (from & PROTECTED) == 0L)) ||
- ((from & IMPLICIT) != (to & IMPLICIT))
+ || (((to & PROTECTED) != 0L) && (from & PROTECTED) == 0L))
+
+ /** Check if flags have changed **/
+ private def modifiedFlags(from: Long, to: Long): Boolean =
+ (from & IMPLICIT) != (to & IMPLICIT)
/** An entity in source code, either a class or a member definition.
* Name is fully-qualified.
@@ -163,7 +166,7 @@ abstract class Changes {
val to = toSym.info
changedTypeParams.clear
- def omitSymbols(s: Symbol): Boolean = !s.hasFlag(LOCAL | LIFTED | PRIVATE)
+ def omitSymbols(s: Symbol): Boolean = !s.hasFlag(LOCAL | LIFTED | PRIVATE | SYNTHETIC)
val cs = new mutable.ListBuffer[Change]
if ((from.parents zip to.parents) exists { case (t1, t2) => !sameType(t1, t2) })
@@ -191,8 +194,12 @@ abstract class Changes {
case _ =>
n.suchThat(ov => sameType(ov.tpe, o.tpe))
}
- if (newSym == NoSymbol || moreRestrictive(o.flags, newSym.flags))
+ if (newSym == NoSymbol || moreRestrictive(o.flags, newSym.flags) || modifiedFlags(o.flags, newSym.flags))
cs += Changed(toEntity(o))(n + " changed from " + o.tpe + " to " + n.tpe + " flags: " + Flags.flagsToString(o.flags))
+ else if (newSym.isGetter && (o.accessed(from).hasFlag(MUTABLE) != newSym.accessed.hasFlag(MUTABLE)))
+ // o.owner is already updated to newSym.owner
+ // so o.accessed will return the accessed for the new owner
+ cs += Changed(toEntity(o))(o.accessed(from) + " changed to " + newSym.accessed)
else
newMembers -= newSym
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 1d795d669f..f62d221320 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1094,11 +1094,13 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
final def constrParamAccessors: List[Symbol] =
info.decls.toList filter (sym => !sym.isMethod && sym.isParamAccessor)
- /** The symbol accessed by this accessor (getter or setter) function.
- */
- final def accessed: Symbol = {
+ /** The symbol accessed by this accessor (getter or setter) function. */
+ final def accessed: Symbol = accessed(owner.info)
+
+ /** The symbol accessed by this accessor function, but with given owner type */
+ final def accessed(ownerTp: Type): Symbol = {
assert(hasFlag(ACCESSOR))
- owner.info.decl(nme.getterToLocal(if (isSetter) nme.setterToGetter(name) else name))
+ ownerTp.decl(nme.getterToLocal(if (isSetter) nme.setterToGetter(name) else name))
}
/** The implementation class of a trait */
diff --git a/test/files/buildmanager/t2792/A1.scala b/test/files/buildmanager/t2792/A1.scala
new file mode 100644
index 0000000000..96dc0ef933
--- /dev/null
+++ b/test/files/buildmanager/t2792/A1.scala
@@ -0,0 +1,3 @@
+object A {
+ val x = new C
+}
diff --git a/test/files/buildmanager/t2792/A2.scala b/test/files/buildmanager/t2792/A2.scala
new file mode 100644
index 0000000000..e55e681c76
--- /dev/null
+++ b/test/files/buildmanager/t2792/A2.scala
@@ -0,0 +1,4 @@
+object B {
+ import A.x.y
+ val z = y
+}
diff --git a/test/files/buildmanager/t2792/A3.scala b/test/files/buildmanager/t2792/A3.scala
new file mode 100644
index 0000000000..cd083cdb34
--- /dev/null
+++ b/test/files/buildmanager/t2792/A3.scala
@@ -0,0 +1,3 @@
+class C {
+ val y = 4
+}
diff --git a/test/files/buildmanager/t2792/t2792.changes/A1_1.scala b/test/files/buildmanager/t2792/t2792.changes/A1_1.scala
new file mode 100644
index 0000000000..00ee05f273
--- /dev/null
+++ b/test/files/buildmanager/t2792/t2792.changes/A1_1.scala
@@ -0,0 +1,3 @@
+object A {
+ var x = new C
+}
diff --git a/test/files/buildmanager/t2792/t2792.check b/test/files/buildmanager/t2792/t2792.check
new file mode 100644
index 0000000000..68e14c6386
--- /dev/null
+++ b/test/files/buildmanager/t2792/t2792.check
@@ -0,0 +1,11 @@
+builder > A1.scala A2.scala A3.scala
+compiling Set(A1.scala, A2.scala, A3.scala)
+Changes: Map()
+builder > A1.scala
+compiling Set(A1.scala)
+Changes: Map(object A -> List(Added(Definition(A.x_$eq)), Changed(Definition(A.x))[value x changed to variable x]))
+invalidate A2.scala because it references changed definition [Changed(Definition(A.x))[value x changed to variable x]]
+compiling Set(A2.scala)
+A2.scala:2: error: stable identifier required, but A.x found.
+ import A.x.y
+ ^
diff --git a/test/files/buildmanager/t2792/t2792.test b/test/files/buildmanager/t2792/t2792.test
new file mode 100644
index 0000000000..f199950bba
--- /dev/null
+++ b/test/files/buildmanager/t2792/t2792.test
@@ -0,0 +1,3 @@
+>>compile A1.scala A2.scala A3.scala
+>>update A1.scala=>A1_1.scala
+>>compile A1.scala