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

Regression in alterationx10/opinionated-zio #18277

Closed
WojciechMazur opened this issue Jul 24, 2023 · 2 comments
Closed

Regression in alterationx10/opinionated-zio #18277

WojciechMazur opened this issue Jul 24, 2023 · 2 comments
Assignees
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore stat:needs spec

Comments

@WojciechMazur
Copy link
Contributor

New regression found in the Open CB: https://github.com/VirtusLab/community-build3/actions/runs/5626149769/job/15249547099

Compiler version

3.3.2-RC1-bin-20230720-98b452d-NIGHTLY
Works in 3.3.1-RC4
Bisect points to: 027923c

Minimized code

import scala.deriving.*
import scala.deriving.Mirror.ProductOf

type UAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x | y]

inline def derived[A](using p: Mirror.ProductOf[A]) = {
    val deps: List[UAnyType[p.MirroredElemTypes]] = ???
    val a = deps.toArray
    // ctx: val a = p.fromProduct(Tuple.fromArray(deps.toArray))
    // In 3.3.0 uses ClassTag[Object]
}

Output

-- [E172] Type Error: /Users/wmazur/projects/sandbox/main.scala:8:24 -----------
8 |    val a = deps.toArray
  |                        ^
  |No ClassTag available for B
  |
  |where:    B is a type variable with constraint >: UAnyType[p.MirroredElemTypes]

Expectation

I'm not sure if this code should compile or should not.
In 3.3.0 this code was using ClassTag[Object] so if it worked user can potentially provide instance of given ClassTag[UAnyType[p.MirroredElemTypes]] = ClassTag.AnyRef.asInstanceOf[...]
Alternatively the context of usage was to create an instance of p using p.fromProduct. Having a variant allowing to use List instead of Array should fix it (currently only Array, IArray and Product is allowed`

@WojciechMazur WojciechMazur added itype:bug area:typer stat:needs spec regression This worked in a previous version but doesn't anymore labels Jul 24, 2023
@odersky
Copy link
Contributor

odersky commented Jul 24, 2023

I think this code should not compile. There is no ClassTag.

@nicolasstucki
Copy link
Contributor

The original code may be fixed with

- val a = p.fromProduct(Tuple.fromArray(deps.toArray))
+ val a = p.fromProduct(Tuple.fromArray((deps: List[Object]).toArray))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore stat:needs spec
Projects
None yet
Development

No branches or pull requests

3 participants