Skip to content

Inline match issue with separate compilation #6157

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

Closed
milessabin opened this issue Mar 24, 2019 · 0 comments
Closed

Inline match issue with separate compilation #6157

milessabin opened this issue Mar 24, 2019 · 0 comments

Comments

@milessabin
Copy link
Contributor

The following compiles correctly as a single source file,

import scala.compiletime._

object Utils {
  type Id[t] = t

  inline def summonAllValues[T] <: T = inline erasedValue[Id[T]] match {
    case _: Unit => ()
    case _: (a, b) => (constValue[a], summonAllValues[b])
  }
}

import Utils._

object Foo {
  type Labels = ("i", ("s", ("b", Unit)))
}

object Test extends App {
  val labels = summonAllValues[Foo.Labels]
}

However, if Utils is split off to a separate source file and compiled first,

import scala.compiletime._

object Utils {
  type Id[t] = t

  inline def summonAllValues[T] <: T = inline erasedValue[Id[T]] match {
    case _: Unit => ()
    case _: (a, b) => (constValue[a], summonAllValues[b])
  }
}

with the following second,

import Utils._

object Foo {
  type Labels = ("i", ("s", ("b", Unit)))
}

object Test extends App {
  val labels = summonAllValues[Foo.Labels]
}

then the latter fails with,

-- Error: tests/pos/inline-match-separate/inline-match-separate_1.scala:6:65 ---
6 |  inline def summonAllValues[T] <: T = inline erasedValue[Id[T]] match {
  |                                       ^
  |cannot reduce inline match with
  | scrutinee:  compiletime.erasedValue[Utils.Id[Foo.Labels]] : Utils.Id[Foo.Labels]
  | patterns :  case _:Unit
  |             case _:Tuple2[a @ _, b @ _]
  | This location is in code that was inlined at inline-match-separate_2.scala:8
7 |    case _: Unit => ()
8 |    case _: (a, b) => (constValue[a], summonAllValues[b])
9 |  }
one error found
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

1 participant