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

whitebox macros aren't so whitebox #8048

Closed
scabug opened this issue Dec 8, 2013 · 4 comments
Closed

whitebox macros aren't so whitebox #8048

scabug opened this issue Dec 8, 2013 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 8, 2013

import scala.reflect.macros.WhiteboxContext
import scala.language.experimental.macros

object Macros {
  def impl(c: WhiteboxContext) = {
    import c.universe._
    q"if (true) Some(2) else None"
  }

  def foo: Any = macro impl
}
object Test extends App {
  val x: Option[Int] = Macros.foo
}
12:25 ~/Projects/Master/sandbox (master)$ scalac Macros.scala && scalac Test.scala
Test.scala:2: error: type mismatch;
 found   : Any
 required: Option[Int]
  val x: Option[Int] = Macros.foo
                              ^
one error found
@scabug
Copy link
Author

scabug commented Dec 8, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8048?orig=1
Reporter: @xeno-by
Affected Versions: 2.11.0-M7

@scabug
Copy link
Author

scabug commented Dec 8, 2013

@xeno-by said:
Caused by pt sometimes leaking into the type of the if, even when the lub of branch types is more precise: https://github.com/scala/scala/blob/d938f59e40e7ba97b199e5f70f252d191c19d93e/src/compiler/scala/tools/nsc/typechecker/Typers.scala#L4221.

@scabug
Copy link
Author

scabug commented Dec 8, 2013

@xeno-by said:
Related: #6992

@scabug
Copy link
Author

scabug commented Dec 8, 2013

@xeno-by said:
scala/scala#3236

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

2 participants