Skip to content

Double vision of top-level definition? #6201

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
liufengyun opened this issue Apr 1, 2019 · 0 comments · Fixed by #6337
Closed

Double vision of top-level definition? #6201

liufengyun opened this issue Apr 1, 2019 · 0 comments · Fixed by #6337

Comments

@liufengyun
Copy link
Contributor

The following code fails to compile:

// assert_1.scala
import scala.quoted._
import scala.tasty._

inline def strip(inline x: String): String =
  ${ stripImpl(x) }

def stripImpl(x: String)(implicit refl: Reflection): Expr[String] =
  x.stripMargin.toExpr

inline def isHello(inline x: String): Boolean =
  ${ isHelloImpl(x) }

def isHelloImpl(x: String)(implicit refl: Reflection): Expr[Boolean] =
  if (x == "hello") true.toExpr else false.toExpr

// test_2.scala
object Test {
  def main(args: Array[String]): Unit = {
    assert(isHello(strip("hello")))
    assert(!isHello(strip("bonjour")))
  }
}

The error log seems to suggest double vision of top-level definition:

-- Error: examples/test_2.scala:3:11 -------------------------------------------
3 |    assert(isHello(strip("hello")))
  |           ^
  |     cannot merge
  |       method isHello of type (x: String @InlineParam): Boolean  and
  |       method isHello of type (x: String @InlineParam): Boolean
  |     they are both defined in package <empty> but have matching signatures
  |       (x: String @InlineParam): Boolean and
  |       (x: String @InlineParam): Boolean
  |     as members of package <empty>
  |
-- Error: examples/test_2.scala:3:19 -------------------------------------------
3 |    assert(isHello(strip("hello")))
  |                   ^
  |     cannot merge
  |       method strip of type (x: String @InlineParam): String  and
  |       method strip of type (x: String @InlineParam): String
  |     they are both defined in package <empty> but have matching signatures
  |       (x: String @InlineParam): String and
  |       (x: String @InlineParam): String
  |     as members of package <empty>
  |
-- Error: examples/test_2.scala:4:12 -------------------------------------------
4 |    assert(!isHello(strip("bonjour")))
  |            ^
  |     cannot merge
  |       method isHello of type (x: String @InlineParam): Boolean  and
  |       method isHello of type (x: String @InlineParam): Boolean
  |     they are both defined in package <empty> but have matching signatures
  |       (x: String @InlineParam): Boolean and
  |       (x: String @InlineParam): Boolean
  |     as members of package <empty>
  |
-- Error: examples/test_2.scala:4:20 -------------------------------------------
4 |    assert(!isHello(strip("bonjour")))
  |                    ^
  |     cannot merge
  |       method strip of type (x: String @InlineParam): String  and
  |       method strip of type (x: String @InlineParam): String
  |     they are both defined in package <empty> but have matching signatures
  |       (x: String @InlineParam): String and
  |       (x: String @InlineParam): String
  |     as members of package <empty>
  |
@liufengyun liufengyun self-assigned this Apr 18, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 18, 2019
nicolasstucki added a commit that referenced this issue Apr 18, 2019
anatoliykmetyuk pushed a commit to dotty-staging/dotty that referenced this issue May 2, 2019
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