Skip to content
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

When falling back to adapt without an expected type, use of resetAttrs leads to unhygenic rebinding #7519

Closed
scabug opened this issue May 25, 2013 · 7 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented May 25, 2013

class C /*#1*/{
  implicit def conversion(m: Int)(implicit nada: Nothing): String = ???

  class C /*#2*/ { // rename class to get correct error.
    locally(0 : String) // "value conversion is not a member of C.this.C"
  }
}

The offending code:

// Typer#adapt
case _ =>
  debuglog("fallback on implicits: " + tree + "/" + resetAllAttrs(original))
  val tree1 = typed(resetAllAttrs(original), mode, WildcardType)
  // Q: `typed` already calls `pluginsTyped` and `adapt`. the only difference here is that
  // we pass `EmptyTree` as the `original`. intended? added in 2009 (53d98e7d42) by martin.
  tree1.tpe = pluginsTyped(tree1.tpe, this, tree1, mode, pt)
  if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt, EmptyTree)

The winning implicit conversion is inferred as a symful Select(This(C#1), "conversion"). The resetAllAttrs brutalizes this tree, and upon retypechecking we end up with This(C#2).

resetLocalAttrs seems like a better option here.

The same problem arises with the two classes share the name "$anon".

trait T; trait U
new T {
  implicit def conversion(m: Int)(implicit nada: Nothing): String = ???

  new U { // rename class to get correct error.
    locally(0 : String) // "value conversion is not a member of U"
  }
}
@scabug
Copy link
Author

scabug commented May 25, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7519?orig=1
Reporter: @retronym
Affected Versions: 2.10.0
Other Milestones: 2.11.0-M7

@scabug
Copy link
Author

scabug commented May 25, 2013

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug scabug closed this as completed Aug 12, 2013
@scabug
Copy link
Author

scabug commented Oct 18, 2013

@harrah said:
The commit (32b5d50d6635320f448c92c27bc6df3acbb04451) in Jason's pull request, included in 2.11.0-M4, fixes sbt issue sbt/sbt#914 (unless I screwed up bisect). A partest test covering the sbt issue is here: harrah/scala@6da26cb. Useful to submit as a pull request? Can the fix be backported to 2.10.x?

@scabug
Copy link
Author

scabug commented Oct 19, 2013

@retronym said (edited on Oct 19, 2013 9:21:09 PM UTC):
Thanks for the precise bisection!

Please submit the test case. I suppose that fix has lived in master for a while without anything blowing up, so we might accept the backport, too, given that it helps SBT usability. That said, almost no-one has tried master in anger as we're only just in a position to start building Scalaz, Specs et al.

@scabug
Copy link
Author

scabug commented Oct 23, 2013

@retronym said:
Backport: scala/scala#3072

@scabug
Copy link
Author

scabug commented Oct 24, 2013

@adriaanm said:
scala/scala#3072

@scabug scabug added the typer label Apr 7, 2017
@scabug scabug added this to the 2.10.4-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants