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
whitebox materializers are only whitebox in type parameters, not type members #8104
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8104?orig=1 |
@paulp said: object Generic extends LowPriorityGeneric {
type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 }
// Refinement for products, here we can provide the calling context with
// a proof that the resulting Repr <: HList
implicit def product[T <: Product]: Generic[T] = macro GenericMacros.materializeForProduct[T]
} |
@xeno-by said: |
@paulp said: |
@xeno-by said: 23:58 ~/Projects/shapeless-test$ sbt compile
[info] Set current project to shapeless-test (in build file:/Users/xeno_by/Projects/shapeless-test/)
[info] Compiling 1 Scala source to /Users/xeno_by/Projects/shapeless-test/target/scala-2.11.0-M7/classes...
X.super.<init>(scala.Tuple2.apply[Int, Char](1, 'b'))
[error] /Users/xeno_by/Projects/shapeless-test/Test.scala:13: could not find implicit value for parameter tupleGeneric: shapeless.Generic.Aux[(Int, Char),shapeless.::[Int,shapeless.::[Char,shapeless.HNil]]]
[error] class X extends A[(Int, Char),shapeless.::[Int,shapeless.::[Char,shapeless.HNil]]]((1, 'b'))
[error] ^ |
@paulp said: |
@xeno-by said (edited on Dec 28, 2013 9:01:14 AM UTC):
This happens because of matchesPt discarding Generic.product as an implicit candidate for a lookup for Generic[T1] { type Repr = T2 } with both T1 and T2 being ground types:
This is quite reasonable, because the Repr type member ruins the subtyping check underlying matchesPt. Repr's counterpart, the T type parameter of Generic, gets wildcarded for the matchesPt check (denoted by the question mark in the printout), whereas Repr does not. |
@xeno-by said (edited on Dec 27, 2013 11:16:24 PM UTC):
This, however, requires 2.11 and is not going to work in 2.10, because fundep materialization was only merged into 2.11 (scala/scala#2499). |
@xeno-by said: |
upd. Note that the original bug report looked differently, involving an anonymous class that inherited from a class that takes an implicit of type Generic.Aux. However, it all boiled down to a very simple reproduction, so I decided to update the description. Therefore if initial comments look confusing to you, don't worry - it's okay. If you really wonder about what was going on, take a look at the issue's history.
The text was updated successfully, but these errors were encountered: