Skip to content

Transparentness of inline defs doesn't propagate #15506

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

Open
prolativ opened this issue Jun 23, 2022 · 3 comments
Open

Transparentness of inline defs doesn't propagate #15506

prolativ opened this issue Jun 23, 2022 · 3 comments

Comments

@prolativ
Copy link
Contributor

Compiler version

3.2.0-RC1

Minimized code

//> using scala "3.2.0-RC1"

class X1
class X2

transparent inline def foo: X1 | X2 =
  new X1

transparent inline def bar: (X1 | X2, X1 | X2) =  
  (foo, foo)

val x: (X1, X1) = bar

Output

[error] ./Transparent.scala:12:19: Found:    (X1 | X2, X1 | X2)
[error] Required: (X1, X1)
[error] val x: (X1, X1) = bar
[error]                   ^^^

Expectation

After inlining the type of x should be known to be (X1, X2) and the entire snippet should compile.

@bishabosha
Copy link
Member

bishabosha commented Jun 23, 2022

I think this is a duplicate of #8739, feel free to reopen if not

@nicolasstucki
Copy link
Contributor

Minimized

transparent inline def foo: Int | Boolean = 2
transparent inline def bar: Option[Int | Boolean] = Some(foo)
val x: Some[Int] = bar

The issue is that we are not refining the inferred type parameter of the Some.apply method. It is similar to #8739.

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jun 23, 2022

Same issue with

transparent inline def bar(x: Int | Boolean): Option[Int | Boolean] = Some(x)
val x: Some[Int] = bar(2)

but this one has a workaround if we use Some[x.type](x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants