Skip to content

Fix #10253: Fix result type of outer accessors #10314

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 4 commits into from
Nov 16, 2020
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ object ExplicitOuter {
private def newOuterSym(owner: ClassSymbol, cls: ClassSymbol, name: TermName, flags: FlagSet)(using Context) = {
val outerThis = owner.owner.enclosingClass.thisType
val outerCls = outerClass(cls)
val prefix = owner.thisType.baseType(cls).normalizedPrefix
val target =
if (owner == cls)
outerCls.appliedRef
else
outerThis.baseType(outerCls).orElse(
outerCls.typeRef.appliedTo(outerCls.typeParams.map(_ => TypeBounds.empty)))
if prefix == NoPrefix then outerCls.typeRef.appliedTo(outerCls.typeParams.map(_ => TypeBounds.empty))
else prefix.widen)
val info = if (flags.is(Method)) ExprType(target) else target
atPhaseNoEarlier(explicitOuterPhase.next) { // outer accessors are entered at explicitOuter + 1, should not be defined before.
newSymbol(owner, name, Synthetic | flags, info, coord = cls.coord)
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i10253.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object test:
def foo(qc: QC): Unit =
object treeMap extends qc.reflect.TreeMap

trait QC:
val reflect: Reflection
trait Reflection:
trait TreeMap:
def transformTree: Unit = ???