Skip to content

Fix #1812, Symbols.mapSymbols shouldn't replace denotations #1832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,35 @@ 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) =>
assert(original.isClass)
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
}

Expand Down
12 changes: 12 additions & 0 deletions tests/pos/i1812.scala
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
11 changes: 11 additions & 0 deletions tests/pos/i1812b.scala
Original file line number Diff line number Diff line change
@@ -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 = ???
}
}