Skip to content

Regression in implicit resoultion for arguments passed by name #18123

Closed
@WojciechMazur

Description

@WojciechMazur

Regression found in Open Communtiy Build in 2 projects:

Compiler version

3.3.2-RC1-bin-20230622-9f15be2-NIGHTLY

Bisect points to eb38e1f

Minimized code

trait P[+T]

extension [T](inline parse0: P[T]) {
  inline def |[V >: T](inline other: P[V]): P[V] = ???
}

// Works if: 
// - parse0 is passed by value or
// - when rep has empty argument list, i.e:  def rep[V]()(using repeater: Implicits.Repeater[T, V]): P[V]
extension [T](inline parse0: => P[T]) {
  inline def rep[V](inline min: Int = 0)(using repeater: Implicits.Repeater[T, V]): P[V] = ???
}

object Implicits {
  trait Repeater[-T, R]
  object Repeater {
    implicit def GenericRepeaterImplicit[T]: Repeater[T, Seq[T]] = ???
  }
}

sealed trait RegexTree
abstract class Node extends RegexTree
class CharClassIntersection() extends Node

def classItem: P[RegexTree] = ???
def charClassIntersection: P[CharClassIntersection] = ???

def x = {
  (charClassIntersection.rep() | classItem.rep())
}

Output

-- [E172] Type Error: /Users/wmazur/projects/dotty/bisect/main.scala:31:33 -----
31 |  (charClassIntersection.rep() | classItem.rep())
   |                                 ^^^^^^^^^^^^^^^
   |No given instance of type Implicits.Repeater[RegexTree, V] was found.
   |I found:
   |
   |    Implicits.Repeater.GenericRepeaterImplicit[T]
   |
   |But method GenericRepeaterImplicit in object Repeater does not match type Implicits.Repeater[RegexTree, V]
   |
   |where:    V is a type variable with constraint <: Seq[CharClassIntersection]

Expectation

Should compile

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

Relationships

None yet

Development

No branches or pull requests

Issue actions