Skip to content

FullParameterization: fix rewiring of Returns #383

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 1 commit into from
Mar 5, 2015
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
6 changes: 6 additions & 0 deletions src/dotty/tools/dotc/transform/FullParameterization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ trait FullParameterization {
} else EmptyTree
}
tree match {
case Return(expr, from) if !from.isEmpty =>
val rewired = rewiredTarget(from, derived)
if (rewired.exists)
tpd.cpy.Return(tree)(expr, Ident(rewired.termRef))
else
EmptyTree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That's a silent failure. Should at least issue ctx.error
  2. From could be an EmptyTree(which means return from enclsoing method), in this case calling
    rewiredTarget(NoSymbol, derived) doesn't make sense.
    Based on this I would better check if from.isEmpty and only if nonempty rewire from

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, EmptyTree here is a sentinel value. Disregard my comment about ctx.error

case Ident(_) => rewireCall(thisRef)
case Select(qual, _) => rewireCall(qual)
case tree @ TypeApply(fn, targs1) =>
Expand Down
1 change: 1 addition & 0 deletions test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class tests extends CompilerTest {
@Test def pos_t2613 = compileFile(posSpecialDir, "t2613")(allowDeepSubtypes)
@Test def pos_packageObj = compileFile(posDir, "i0239")
@Test def pos_anonClassSubtyping = compileFile(posDir, "anonClassSubtyping")
@Test def pos_extmethods = compileFile(posDir, "extmethods")

@Test def pos_all = compileFiles(posDir, failedOther)

Expand Down
1 change: 1 addition & 0 deletions tests/pos/extmethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ class T[A, This <: That1[A]](val x: Int) extends AnyVal {
self: This =>
var next: This = _
final def loop(x: This, cnt: Int): Int = loop(x, cnt + 1)
def const[B](): Boolean = return true
}