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 lookup failure in method local types #4975

Closed
scabug opened this issue Sep 7, 2011 · 4 comments
Closed

Implicit lookup failure in method local types #4975

scabug opened this issue Sep 7, 2011 · 4 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Sep 7, 2011

Implicit lookup fails in method local types.

class LocalImplicitTezt {

    trait Foo[x]

    class TestOk {
        trait My
        object My {
            implicit def Foo[My]: Foo[My] = new Foo[My] {}
        }

        implicitly[Foo[My]]
    }

    def testNo {
        trait My
        object My {
            implicit def Foo[My]: Foo[My] = new Foo[My] {}
        }

        implicitly[Foo[My]] // could not find implicit value for parameter e: LocalImplicitTezt.this.Foo[My]
    }

}
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 7, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4975?orig=1
Reporter: @okomok
Affected Versions: 2.9.1

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 7, 2011

@paulp said:
That's a little perverse. It does work if you skip the companion object.

trait My
implicit def Foo[My]: Foo[My] = new Foo[My] {}
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Dec 4, 2011

@milessabin said:
I've just tripped over something that looks very similar,

object ImplicitScope {
  class A[T]
  object B {
    implicit def ab = new A[B.type]
  }
  
  implicitly[A[B.type]]     // OK
  
  def foo {
    object B2 {
      implicit def ab = new A[B2.type]
    }
    
    implicitly[A[B2.type]]  // Error
  }
}

With the latest trunk I see,

miles@lewis:SI-4975$ scalac-trunk src/implicitscope.scala
src/implicitscope.scala:14: error: could not find implicit value for parameter e: ImplicitScope.A[B2.type]
    implicitly[A[B2.type]]
              ^
one error found
miles@lewis:SI-4975$ scalac-trunk -version
Scala compiler version 2.10.0.r26094-b20111201020254 -- Copyright 2002-2011, LAMP/EPFL
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 20, 2012

@scabug scabug closed this May 23, 2012
@scabug scabug added the implicit label Apr 7, 2017
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.