question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit value can no longer be accessed via implicit conversion

See original GitHub issue

Community build regression for https://github.com/giiita/refuel (maintainer @giiita) Based on Open Community Build #1884 Part of https://github.com/lampepfl/dotty/issues/15647 regressions tracker

Compiler version

Works in 3.1.1 Fails in 3.1.2 and 3.1.3 Fails in 3.2.0-RC* and 3.2.1-RC1-bin-20220711-6efd92d-NIGHTLY

Minimized code

trait JsonRowEntry {
  def readAs[E](implicit c: Read[E]): Option[E] = ???
}
trait Read[T]
trait Codec[T] extends Read[T]
trait CodecTypeProjection[C[_]]
object JsonTransform  {
  given SetCodec[T, C[_]: CodecTypeProjection]: scala.Conversion[C[T], C[Set[T]]] = ???
  given SetCodecExp[T, C[_]: CodecTypeProjection](using codec: C[T]): C[Set[T]] = codec
  given Codec[String] = ???
  given CodecTypeProjection[Read] = ???
}

@main def Test() = {
  import JsonTransform.given
  val tree = new JsonRowEntry {}
  tree.readAs[Set[String]]
}

Output

rror] ./test.scala:17:27: No given instance of type Read[Set[String]] was found for parameter c of method readAs in trait JsonRowEntry.
[error] I found:
[error] 
[error]     JsonTransform.SetCodecExp[String, C](
[error]       JsonTransform.given_CodecTypeProjection_Read
[error]     , /* missing */summon[C[String]])
[error] 
[error] But no implicit values were found that match type C[String].
[error]   tree.readAs[Set[String]]
[error]              

Expectation

Should be able to find correct implicit value by usage of implicit conversion

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
griggtcommented, Jul 14, 2022

First bad commit is db5956b36a7e62b77f4b3a9335ab1587e0e47e2c from #13886

1reaction
oderskycommented, Jul 16, 2022

Is this behavior also expected? @odersky

Probably. It looks similar. We know for sure if it is the same commit that broke it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can an implicit conversion of an implicit value satisfy an ...
Short answer: no. Scala's compiler will only ever look to apply a single implicit, so if it fails to spot an implicit int...
Read more >
Implicit conversions - cppreference.com
This conversion initializes a temporary object of type T from the prvalue by evaluating the prvalue with the temporary object as its result...
Read more >
Implicit Implications (part 2): Implicit Conversions - Rally Health
The best practice here is to never define implicit conversions on primitive or collection types.
Read more >
Can't convert a function to a trait using an implicit conversion ...
It seems that the function needs to be fully specified to make the implicit conversion happen. Otherwise you get an 'missing parameter type' ......
Read more >
Conversions - C# language specification - Microsoft Learn
Example: For instance, the conversion from type int to type long is implicit, so expressions of type int can implicitly be treated as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found