Skip to content

Regression in frawa/typed-json for typer / implicit search #21249

Closed as not planned
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in frawa/typed-json - https://github.com/VirtusLab/community-build3/actions/runs/10043516433/job/27756747215

Not exactly sure if it should be fixed. The compiler is now more precise which might be an improvement. I'm not sure how to workaround it though without explicitly hinting the type

Compiler version

Since 3.4.1
Last good release: 3.4.1-RC1-bin-20240126-1716bcd-NIGHTLY
First bad release: 3.4.1-RC1-bin-20240129-b20747d-NIGHTLY

Probable cause: #19096

Minimized code

sealed trait Keyword
sealed trait AssertionKeyword extends Keyword
sealed trait TypeKeyword extends AssertionKeyword
case object NullTypeKeyword extends TypeKeyword

case class Keywords(keywords: Set[Keywords.KeywordWithLocation])
object Keywords:
  type KeywordWithLocation = WithLocation[Keyword]

case class WithLocation[+T](uri: String, value: T)

trait Compare[A, B]
object Compare extends ComparePriority2:
  given compareSubtypeWithSupertype[A, B](using A <:< B): Compare[A, B] = ???
trait ComparePriority2:
  given compareSupertypeWithSubtype[A, B](using A <:< B): Compare[B, A] = ???

class KeywordsTest:
  private def assertKeywords(f: Keywords => Unit): Either[Nothing, Unit] = ???
  def assertEquals[A, B](obtained: A, expected: B)(using Compare[A, B]) = ???
  val keywords: Keywords = ???
  assertEquals(keywords.keywords, Set(WithLocation("", NullTypeKeyword))) // error
  // Summon resolves to: 
  // - in 3.4.1 Compare.compareSubtypeWithSupertype[Set[Keywords.KeywordWithLocation], Set[WithLocation[Keyword]]]
  // - in 3.4.2 Compare.compareSubtypeWithSupertype[Set[Keywords.KeywordWithLocation], Set[WithLocation[NullTypeKeyword.type]]]

Output

-- [E172] Type Error: /Users/wmazur/projects/sandbox/src/main/scala/test.scala:22:73 
22 |  assertEquals(keywords.keywords, Set(WithLocation("", NullTypeKeyword))) // error
   |                                                                         ^
   |No given instance of type Compare[Set[Keywords.KeywordWithLocation],
   |  Set[WithLocation[NullTypeKeyword.type]]] was found for parameter x$3 of method assertEquals in class KeywordsTest.
   |I found:
   |
   |    Compare.compareSubtypeWithSupertype[Set[Keywords.KeywordWithLocation],
   |      Set[WithLocation[NullTypeKeyword.type]]](
   |      /* missing */
   |        summon[Set[Keywords.KeywordWithLocation] <:<
   |          Set[WithLocation[NullTypeKeyword.type]]]
   |    )
   |
   |But no implicit values were found that match type Set[Keywords.KeywordWithLocation] <:< Set[WithLocation[NullTypeKeyword.type]].

Expectation

Not sure, but maybe it should still compile.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions