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

String no longer taken as generic SeqOps #14927

Closed
mcallisto opened this issue Apr 13, 2022 · 4 comments
Closed

String no longer taken as generic SeqOps #14927

mcallisto opened this issue Apr 13, 2022 · 4 comments
Assignees
Labels

Comments

@mcallisto
Copy link

Compiler version

Scala 3.1.2

Minimized code

import scala.collection.SeqOps
def foo[A, CC[B] <: SeqOps[B, CC, CC[B]]](seq: CC[A]): CC[A] = seq.tail
def test: Unit = foo("ABC")

Output

Found:    ("ABC" : String)
Required: collection.SeqOps[A, 
  [B] =>> 
    collection.SeqOps[B, 
      [B] =>> 
        collection.SeqOps[B², 
          [B] =>> 
            ...collection.SeqOps[B³, [B] =>> ...[..., ..., ...], 
              ...SeqOps[B³, [B...] =>> ..., ...[..., ..., ...]]
            ]
        , 
          collection.SeqOps[B², [B] =>> ...SeqOps[B⁴², ..., ...], 
            ....SeqOps[B², [B] =>> ..., ...[..., ..., ...]]
          ]
        ]
    , 
      collection.SeqOps[B, 
        [B] =>> 
          collection.SeqOps[B⁵⁷, [B] =>> ...SeqOps[B⁵⁸, ..., ...], 
            ....SeqOps[B⁵⁷, [B] =>> ..., ...[..., ..., ...]]
          ]
      , 
        collection.SeqOps[B, 
          [B] =>> ....SeqOps[B⁶⁶, [B] =>> ..., ...[..., ..., ...]]
        , 
          ...collection.SeqOps[B, [B] =>> ...[..., ..., ...], 
            ...SeqOps[B, ..., ...]
          ]
        ]
      ]
    ]
, 
  collection.SeqOps[A, 
    [B] =>> 
      collection.SeqOps[B⁷³, 
        [B] =>> 
          ...collection.SeqOps[B⁷⁴, [B] =>> ...[..., ..., ...], 
            ...SeqOps[B⁷⁴, [B...] =>> ..., ...[..., ..., ...]]
          ]
      , 
        collection.SeqOps[B⁷³, 
          [B] =>> ...SeqOps[B⁷⁸, [B...] =>> ..., ...[..., ..., ...]]
        , ....SeqOps[B⁷³, [B] =>> ...[..., ..., ...], ...SeqOps[..., ..., ...]]]
      ]
  , 
    collection.SeqOps[A, 
      [B] =>> 
        collection.SeqOps[B⁸², [B] =>> ...SeqOps[B⁸³, ..., ...], 
          ....SeqOps[B⁸², [B] =>> ..., ...[..., ..., ...]]
        ]
    , 
      collection.SeqOps[A, 
        [B] =>> ....SeqOps[B⁸⁶, [B] =>> ..., ...[..., ..., ...]]
      , 
        ...collection.SeqOps[A, [B] =>> ...[..., ..., ...], 
          ...SeqOps[A, [B...] =>> ..., ...[..., ..., ...]]
        ]
      ]
    ]
  ]
]

where:    A   is a type variable
          B   is a type variable
          B²  is a type variable
          B²² is a type variable
          B²³ is a type variable
          B²¹ is a type variable
          B²⁰ is a type variable
          B²⁴ is a type variable
          B²⁵ is a type variable
          B²⁶ is a type variable
          B²⁷ is a type variable
          B²⁸ is a type variable
          B²⁹ is a type variable
          B³  is a type variable
          B³² is a type variable
          B³³ is a type variable
          B³¹ is a type variable
          B³⁰ is a type variable
          B³⁴ is a type variable
          B³⁵ is a type variable
          B³⁶ is a type variable
          B³⁷ is a type variable
          B³⁸ is a type variable
          B³⁹ is a type variable
          B¹² is a type variable
          B¹³ is a type variable
          B¹¹ is a type variable
          B¹⁰ is a type variable
          B¹⁴ is a type variable
          B¹⁵ is a type variable
          B¹⁶ is a type variable
          B¹⁷ is a type variable
          B¹⁸ is a type variable
          B¹⁹ is a type variable
          B⁴  is a type variable
          B⁴² is a type variable
          B⁴³ is a type variable
          B⁴¹ is a type variable
          B⁴⁰ is a type variable
          B⁴⁴ is a type variable
          B⁴⁵ is a type variable
          B⁴⁶ is a type variable
          B⁴⁷ is a type variable
          B⁴⁸ is a type variable
          B⁴⁹ is a type variable
          B⁵  is a type variable
          B⁵² is a type variable
          B⁵³ is a type variable
          B⁵¹ is a type variable
          B⁵⁰ is a type variable
          B⁵⁴ is a type variable
          B⁵⁵ is a type variable
          B⁵⁶ is a type variable
          B⁵⁷ is a type variable
          B⁵⁸ is a type variable
          B⁵⁹ is a type variable
          B⁶  is a type variable
          B⁶² is a type variable
          B⁶³ is a type variable
          B⁶¹ is a type variable
          B⁶⁰ is a type variable
          B⁶⁴ is a type variable
          B⁶⁵ is a type variable
          B⁶⁶ is a type variable
          B⁶⁷ is a type variable
          B⁶⁸ is a type variable
          B⁶⁹ is a type variable
          B⁷  is a type variable
          B⁷² is a type variable
          B⁷³ is a type variable
          B⁷¹ is a type variable
          B⁷⁰ is a type variable
          B⁷⁴ is a type variable
          B⁷⁵ is a type variable
          B⁷⁶ is a type variable
          B⁷⁷ is a type variable
          B⁷⁸ is a type variable
          B⁷⁹ is a type variable
          B⁸  is a type variable
          B⁸² is a type variable
          B⁸³ is a type variable
          B⁸¹ is a type variable
          B⁸⁰ is a type variable
          B⁸⁴ is a type variable
          B⁸⁵ is a type variable
          B⁸⁶ is a type variable
          B⁸⁷ is a type variable
          B⁸⁸ is a type variable
          B⁸⁹ is a type variable
          B⁹  is a type variable

Expectation

In Scala 3.1.1 and before the code compiles just fine.

As mentioned by @nicolasstucki here where first reported https://users.scala-lang.org/t/scala-3-1-2-change-string-no-longer-working-with-seqops/8424, the issue seems to be related with the implicit conversion from String into Seq[Char].

@mcallisto mcallisto added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 13, 2022
@romanowski romanowski added area:implicits related to implicits and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 13, 2022
@odersky odersky added the regression This worked in a previous version but doesn't anymore label May 26, 2022
@odersky odersky added this to the 3.2.0-RC1 milestone May 26, 2022
@odersky
Copy link
Contributor

odersky commented May 26, 2022

Can be get a bisection for this one? It looks like a fairly serious regression.

@odersky
Copy link
Contributor

odersky commented May 26, 2022

Running on latest main I get a different error message:

-- [E007] Type Mismatch Error: ../new/test.scala:3:21 --------------------------
3 |def test: Unit = foo("ABC")
  |                     ^^^^^
  |Found:    ("ABC" : String)
  |Required: CC[A]
  |
  |where:    A  is a type variable
  |          CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]]
  |
  | longer explanation available when compiling with `-explain`
1 error found

@griggt
Copy link
Collaborator

griggt commented May 26, 2022

Bisection says the first bad commit is db5956b from #13886

@anatoliykmetyuk anatoliykmetyuk modified the milestones: 3.2.0-RC1, 3.1.3 May 30, 2022
@odersky
Copy link
Contributor

odersky commented May 30, 2022

I note it does not work for Scala 2.13 either. I get

i14927.scala:4: error: inferred type arguments [String,Comparable] do not conform to method foo's type parameter bounds [A,CC[B] <: scala.collection.SeqOps[B,CC,CC[B]]]
  def test: Unit = foo("ABC")
                   ^
i14927.scala:4: error: type mismatch;
 found   : String("ABC")
 required: CC[A]
  def test: Unit = foo("ABC")
                       ^
2 errors

I believe the 3.1.1 behavior was a spurious error. Which conversion do we think should be inserted to make this work?

@odersky odersky added stat:needs info and removed itype:bug regression This worked in a previous version but doesn't anymore labels May 30, 2022
@odersky odersky removed this from the 3.1.3 milestone May 30, 2022
@odersky odersky closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants