aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-12-20 17:18:30 +0100
committerGitHub <noreply@github.com>2016-12-20 17:18:30 +0100
commit098c50ac83eb4d18b23a1ed888cf601053c46ae6 (patch)
treed5c45fd83ebccf3c8dc923e41e695723a3c04a1a
parentafa83099a2300fcd09afe6514f9112c75f9fb4dc (diff)
parenta7d17e286760879a35dfaeeadca1dbad2aa85dfc (diff)
downloaddotty-098c50ac83eb4d18b23a1ed888cf601053c46ae6.tar.gz
dotty-098c50ac83eb4d18b23a1ed888cf601053c46ae6.tar.bz2
dotty-098c50ac83eb4d18b23a1ed888cf601053c46ae6.zip
Merge pull request #1832 from dotty-staging/fix-1810
Fix #1812, Symbols.mapSymbols shouldn't replace denotations
-rw-r--r--compiler/src/dotty/tools/dotc/core/Symbols.scala24
-rw-r--r--tests/pos/i1812.scala12
-rw-r--r--tests/pos/i1812b.scala11
3 files changed, 40 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala
index d355686ab..5d0dd2123 100644
--- a/compiler/src/dotty/tools/dotc/core/Symbols.scala
+++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala
@@ -316,10 +316,7 @@ trait Symbols { this: Context =>
newNakedSymbol[original.ThisName](original.coord)
}
val ttmap1 = ttmap.withSubstitution(originals, copies)
- (originals, copies).zipped foreach {(original, copy) =>
- copy.denot = original.denot // preliminary denotation, so that we can access symbols in subsequent transform
- }
- (originals, copies).zipped foreach {(original, copy) =>
+ (originals, copies).zipped foreach { (original, copy) =>
val odenot = original.denot
val oinfo = original.info match {
case ClassInfo(pre, _, parents, decls, selfInfo) =>
@@ -327,14 +324,27 @@ trait Symbols { this: Context =>
ClassInfo(pre, copy.asClass, parents, decls.cloneScope, selfInfo)
case oinfo => oinfo
}
+
+ val completer = new LazyType {
+ def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
+ denot.info = oinfo // needed as otherwise we won't be able to go from Sym -> parents & etc
+ // Note that this is a hack, but hack commonly used in Dotty
+ // The same thing is done by other completers all the time
+ denot.info = ttmap1.mapType(oinfo)
+ denot.annotations = odenot.annotations.mapConserve(ttmap1.apply)
+ }
+ }
+
copy.denot = odenot.copySymDenotation(
symbol = copy,
owner = ttmap1.mapOwner(odenot.owner),
- initFlags = odenot.flags &~ Frozen | Fresh,
- info = ttmap1.mapType(oinfo),
+ initFlags = odenot.flags &~ (Frozen | Touched) | Fresh,
+ info = completer,
privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here.
- annotations = odenot.annotations.mapConserve(ttmap1.apply))
+ annotations = odenot.annotations)
+
}
+
copies
}
diff --git a/tests/pos/i1812.scala b/tests/pos/i1812.scala
new file mode 100644
index 000000000..653274883
--- /dev/null
+++ b/tests/pos/i1812.scala
@@ -0,0 +1,12 @@
+class FF[R] {
+ def compose(): R = ???
+}
+
+class Test(x: Int) extends AnyVal {
+ def method: Unit = {
+ class Bla
+ class Foo extends FF[Bla] {
+ override def compose() = super[FF].compose()
+ }
+ }
+}
diff --git a/tests/pos/i1812b.scala b/tests/pos/i1812b.scala
new file mode 100644
index 000000000..492c545f1
--- /dev/null
+++ b/tests/pos/i1812b.scala
@@ -0,0 +1,11 @@
+class FF[R] {
+ def compose(): R = ???
+}
+
+class Test(x: Int) extends AnyVal {
+ def method: Unit = {
+ class Bla{ def bar:a.S = ???}
+ trait TRT{ type S}
+ val a: TRT = ???
+ }
+}