Permalink
Browse files

[nomaster] SI-7519 Less brutal attribute resetting in adapt fallback

Prefers `resetLocalAttrs` over `resetAllAttrs`. The latter loses
track of which enclosing class of the given name is referenced by
a `This` node which prefixes the an applied implicit view.

The code that `resetAllAttrs` originally landed in: d4c63b#L6R804

Cherry picked from 433880e

Conflicts:
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
  • Loading branch information...
1 parent e6a5e69 commit ce74bb00603f23087fbd3b0fe2870f09d73bb676 @retronym retronym committed May 25, 2013
Showing with 28 additions and 2 deletions.
  1. +3 −2 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  2. +7 −0 test/files/neg/t7519.check
  3. +18 −0 test/files/neg/t7519.scala
@@ -876,8 +876,9 @@ trait Typers extends Modes with Adaptations with Tags {
case SilentResultValue(result) =>
result
case _ =>
- debuglog("fallback on implicits: " + tree + "/" + resetAllAttrs(original))
- val tree1 = typed(resetAllAttrs(original), mode, WildcardType)
+ val resetTree = resetLocalAttrs(original)
+ debuglog(s"fallback on implicits: ${tree}/$resetTree")
+ val tree1 = typed(resetTree, 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)
@@ -0,0 +1,7 @@
+t7519.scala:5: error: could not find implicit value for parameter nada: Nothing
+ locally(0 : String) // was: "value conversion is not a member of C.this.C"
+ ^
+t7519.scala:15: error: could not find implicit value for parameter nada: Nothing
+ locally(0 : String) // was: "value conversion is not a member of U"
+ ^
+two errors found
@@ -0,0 +1,18 @@
+class C {
+ implicit def conversion(m: Int)(implicit nada: Nothing): String = ???
+
+ class C { // rename class to get correct error, can't find implicit: Nothing.
+ locally(0 : String) // was: "value conversion is not a member of C.this.C"
+ }
+}
+
+object Test2 {
+ trait T; trait U
+ new T {
+ implicit def conversion(m: Int)(implicit nada: Nothing): String = ???
+
+ new U { // nested anonymous classes also share a name.
+ locally(0 : String) // was: "value conversion is not a member of U"
+ }
+ }
+}

0 comments on commit ce74bb0

Please sign in to comment.