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

implicit not found when anonymous class in prefix #7869

Closed
scabug opened this issue Sep 23, 2013 · 4 comments
Closed

implicit not found when anonymous class in prefix #7869

scabug opened this issue Sep 23, 2013 · 4 comments

Comments

@scabug
Copy link

scabug commented Sep 23, 2013

object TestWorksheet {

  object A {
    implicit final def AtoB(x: A): B = new B
  }
  class A
  class AA extends A

  class B {
    def fun() = {}
  }
  
  //implicit def AtoB(x: A) = new B
  
  (new A) .fun() // it works with A
  (new AA).fun() // it works with a subclasses from A
  
  // but id doesn't work with an anonymous class extending A
  //(new A{var x = 1}).fun() // does not compile
 
  /*
   * Note that it works, when we use implicit classes
   */
  {
    implicit def C(x: A) = new B
    (new A)  .fun()
    (new A{}).fun()
  }
}
@scabug
Copy link
Author

scabug commented Sep 23, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7869?orig=1
Reporter: florian kirmaier (florian.kirmaier)
Affected Versions: 2.10.2
See #6892

@scabug
Copy link
Author

scabug commented Sep 23, 2013

florian kirmaier (florian.kirmaier) said:
note that the example works, when a identity function is used before the implicit conversion

def id[A](x: A): A = x
id(new A{var x = 1}).fun()

@scabug
Copy link
Author

scabug commented Oct 25, 2013

florian kirmaier (florian.kirmaier) said:
This is essentially this Stackoverflow question: http://stackoverflow.com/questions/7760906/implicit-views-in-companion-object

@SethTisue
Copy link
Member

Seems fixed in 2.13.0. I don't know what change helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants