Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Workaround #1895: Bringing a symbol to a new run is broken
  • Loading branch information
smarter committed Jan 28, 2017
commit 51a458efeeebfeed6c357d56cf8afe5b06e86724
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ trait SymDenotations { this: Context =>
else {
val initial = denot.initial
val firstPhaseId = initial.validFor.firstPhaseId.max(ctx.typerPhase.id)
if ((initial ne denot) || ctx.phaseId != firstPhaseId)
ctx.withPhase(firstPhaseId).stillValidInOwner(initial)
else
if ((initial ne denot) || ctx.phaseId != firstPhaseId) {
ctx.withPhase(firstPhaseId).stillValidInOwner(initial) ||
// Workaround #1895: A symbol might not be entered into an owner
// until the second phase where it exists
(denot.validFor.containsPhaseId(firstPhaseId + 1)) &&
ctx.withPhase(firstPhaseId + 1).stillValidInOwner(initial)
} else
stillValidInOwner(denot)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
// not generate them again.
if (!(valueClass is Scala2x)) ctx.atPhase(thisTransformer) { implicit ctx =>
for (decl <- valueClass.classInfo.decls) {
if (isMethodWithExtension(decl))
decls1.enter(createExtensionMethod(decl, moduleClassSym.symbol))
if (isMethodWithExtension(decl)) {
val meth = createExtensionMethod(decl, moduleClassSym.symbol)
decls1.enter(meth)
// Workaround #1895: force denotation of `meth` to be
// at phase where `meth` is entered into the decls of a class
meth.denot(ctx.withPhase(thisTransformer.next))
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/repl/vc.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scala> class Foo(x: Int) extends AnyVal { def hi: Int = 1 }
defined class Foo
scala> new Foo(1).hi
val res0: Int = 1
scala> :quit