Skip to content

Implicit conversion not applied for the arguments of extension method #15998

Closed
@WojciechMazur

Description

@WojciechMazur

Regression found in Open CB #4749 for scala-tessella/ring-seq
Part of the Scala 3.2.1-RC1 regression tracker #15949

Gathering bisect info might be problematic, due to another regression existing in 3.1.2 fixed in 3.1.3

Compiler version

Fails in 3.1.3, 3.2.0, 3.2.1-RC1
Works in 3.1.1

Minimized code

import scala.collection.SeqOps

trait ComparingOps:
  extension[A, CC[B] <: SeqOps[B, CC, CC[B]]](ring: CC[A])
    def isRotationOf(that: CC[A]): Boolean = ???

object RingSeq extends ComparingOps 
import RingSeq.*

@main def Test = 
  RingSeq.isRotationOf("DAB") // error
  "ABCD".isRotationOf("DAB")  // error
  
  // workaround 
  RingSeq.isRotationOf[Char, IndexedSeq]("DAB")
  RingSeq.isRotationOf(wrapString("DAB"))
  wrapString("ABCD").isRotationOf("DAB")

Output

ompiling project (Scala 3.2.2-RC1-bin-20220907-a503b7a-NIGHTLY, JVM)
[error] ./repo4/repro/test.scala:11:24: 
[error] Found:    ("DAB" : String)
[error] Required: CC[A]
[error] 
[error] where:    A  is a type variable
[error]           CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]]
[error]   RingSeq.isRotationOf("DAB") // error
[error]                        ^^^^^
[error] ./repo4/repro/test.scala:12:3: value isRotationOf is not a member of String.
[error] An extension method was tried, but could not be fully constructed:
[error] 
[error]     RingSeq.isRotationOf[A, CC]("ABCD")    failed with
[error] 
[error]         Found:    ("ABCD" : String)
[error]         Required: CC[A]
[error]         
[error]         where:    A  is a type variable
[error]                   CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]]
[error]         
[error]   "ABCD".isRotationOf("DAB")  // error

Expectation

Should compile by applying implicit conversion

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugregressionThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions