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

Inline match widening constant types #13161

Closed
nicolasstucki opened this issue Jul 27, 2021 · 1 comment · Fixed by #18455
Closed

Inline match widening constant types #13161

nicolasstucki opened this issue Jul 27, 2021 · 1 comment · Fixed by #18455

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.0.1

Minimized code

transparent inline def f: String =
  inline 10 match
    case _ =>
      inline Some["foo"]("foo") match
        case Some(x) => x

def test =
  inline val failMsg = f

Output

8 |  inline val failMsg = f
  |                       ^
  |                       inline value must have a literal constant type

Expectation

Should compile.

It looks like the type parameter of the Some.unapply is widened at some point. I would expect the inline match to be typed as:

inline Some.apply["foo"]("foo") match 
    case Some.unapply["foo"](x @ _) => x:"foo"
@nicolasstucki
Copy link
Contributor Author

Now the issue is that we generate an unnecessary binding

        inline val failMsg: String =
          {
            val x: ("foo" : String) = "foo"
            x:String
          }

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

Successfully merging a pull request may close this issue.

1 participant