Skip to content

Regression in squeryl/squeryl, changed semantics of implicits import #18316

Closed
@WojciechMazur

Description

@WojciechMazur

Regression found in Open Community Build for squeryl/squeryl, build logs - https://github.com/VirtusLab/community-build3/actions/runs/5695846723/job/15440936970

Double import of implicits excludes them from search path, or sets their priority to be lower then the inherited implicits.

Compiler version

3.3.2-RC1-bin-20230724-ce1ce99-NIGHTLY

Bisect points to 650f854

Minimized code

// squerel
import scala.language.implicitConversions
object squerel {
  trait EqualityExpression
  object PrimitiveTypeMode:
    implicit def intToTE(f: Int): TypedExpression[Int] = ???

  trait TypedExpression[A1]:
    def ===[A2](b: TypedExpression[A2]): EqualityExpression = ???
}

object scalactic {
  trait TripleEqualsSupport:
    class Equalizer[L](val leftSide: L):
      def ===(rightSide: Any): Boolean = ???

  trait TripleEquals extends TripleEqualsSupport:
    implicit def convertToEqualizer[T](left: T): Equalizer[T] = ???
}

import squerel.PrimitiveTypeMode._ // remove to make code compile
object Test extends scalactic.TripleEquals {
  import squerel.PrimitiveTypeMode._
  val fails: squerel.EqualityExpression = 1 === 1
}

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/dotty/bisect/main.scala:24:42 
24 |  val fails: squerel.EqualityExpression = 1 === 1
   |                                          ^^^^^^^
   |                                    Found:    Boolean
   |                                    Required: squerel.EqualityExpression

Expectation

It should allow to compile the code. Change in order of implicits resolution should not be applied in 3.3.x releases.

Additional feature requrest:
It would be great if we would be able to use both def === methods - before regression it would only pick method from squerel, after the change only from scalactic. If possible it should be able to compile following snippet:

  val x: Boolean = 1 === 1
  val y: squerel.EqualityExpression = 1 === 1

Metadata

Metadata

Assignees

Labels

area:implicitsrelated to implicitsitype:bugregressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions