Skip to content

track values of implicit vals when types depend on it #6139

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

Open
scabug opened this issue Jul 25, 2012 · 3 comments
Open

track values of implicit vals when types depend on it #6139

scabug opened this issue Jul 25, 2012 · 3 comments
Labels
dependent types enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer
Milestone

Comments

@scabug
Copy link

scabug commented Jul 25, 2012

https://gist.github.com/2943283

class Indirection[T](implicit val c: CompanionProvider[T]) {
  def indirect: c.CompanionT = c.provide
}

// error: value foo is not a member of _1.c.CompanionT
new Indirection[Foo].indirect.foo

this doesn't work because new Indirection[Foo]: Indirection[Foo],
i.e., there's no information about the implicit value that was inferred for c in the type of the target of the selection of indirect

@scabug
Copy link
Author

scabug commented Jul 25, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6139?orig=1
Reporter: @adriaanm

@scabug
Copy link
Author

scabug commented Aug 5, 2013

@retronym said:
An example from the mailing lists:

sealed trait EntityRef {
  type RefId
}

trait ProductRef extends EntityRef {
  type RefId = Boolean
}

object SomeAction {
  implicit def rootRef2Id[T <: EntityRef](ref: T): ref.RefId = ???
  def handle(c: ProductRef) {
     locally(c: Boolean)
  }
} 

Implicit search approximates the type of `rootRef2Id` as `(?) => ?#RefId`. This happens here in Implicits.scala [1].

I have added this example to SI-6139 [2]. It is unlikely we'll touch this in 2.11, so you might need to pursue a different approach.

-jason

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@scala scala deleted a comment from scabug Mar 2, 2018
@SethTisue
Copy link
Member

It compiles in Scala 3.5.1.

@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent types enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer
Projects
None yet
Development

No branches or pull requests

2 participants