Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
WojciechMazur opened this issue Sep 8, 2022 · 1 comment · Fixed by #16001
Closed

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

WojciechMazur opened this issue Sep 8, 2022 · 1 comment · Fixed by #16001
Labels
itype:bug regression This worked in a previous version but doesn't anymore stat:needs triage Every issue needs to have an "area" and "itype" label
Milestone

Comments

@WojciechMazur
Copy link
Contributor

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

@WojciechMazur WojciechMazur added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label regression This worked in a previous version but doesn't anymore labels Sep 8, 2022
@WojciechMazur WojciechMazur changed the title Implicit conversion is not applied for the arguments of extenion method Implicit conversion not applied for the arguments of extension method Sep 8, 2022
@odersky
Copy link
Contributor

odersky commented Sep 8, 2022

Another fallout of #13886. The conversions target type is CC[A] which is classified to be underspecified.

More specifically: this change
Refine checking for underspecified implicit queries)

odersky added a commit to dotty-staging/dotty that referenced this issue Sep 8, 2022
smarter added a commit that referenced this issue Sep 9, 2022
)

Two improvements for implicit searches involving type variables.

1. We now always add a comment when an implicit search is rejected due
to the "too unspecific" criterion of #13886, commit
[Refine checking for underspecified implicit
queries](db5956b).

There have been quite a few regressions that hit that problem, so it is
good to know immediately what
   the issue is. 

2. There is now a better wildcard approximation of higher-kinded type
applications. This makes several programs (including original #15998)
compile, which were classified as not specific enough before.

Fixes #15998
Fixes #15820
Fixes #15670
Fixes #15160 
Fixes #13986
Kordyjan pushed a commit to dotty-staging/dotty that referenced this issue Sep 15, 2022
mpollmeier pushed a commit to mpollmeier/dotty that referenced this issue Oct 16, 2022
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug regression This worked in a previous version but doesn't anymore stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants