Skip to content

Wrong position for inlined pure arguments #6026

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
nicolasstucki opened this issue Mar 6, 2019 · 0 comments
Closed

Wrong position for inlined pure arguments #6026

nicolasstucki opened this issue Mar 6, 2019 · 0 comments

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  inline def fun(x: String): String = x
  def foo = fun("abc")
}
sbt:dotty> dotc Foo.scala -Xprint:front -Yprint-pos -Ydebug-pos
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running (fork) dotty.tools.dotc.Main -classpath /Users/nicolasstucki/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar:/Users/nicolasstucki/GitHub/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.14/dotty-library_0.14-0.14.0-bin-SNAPSHOT.jar Foo.scala -Xprint:front -Yprint-pos -Ydebug-pos
result of Foo.scala after frontend:
package <empty>@Foo.scala<0..0> {
  class Foo() extends [email protected]<6..6>@
    Foo.scala<6..6>
  ()@Foo.scala<6..6> { 
    inline def fun(
      x: [email protected]<32..38>@
        Foo.scala[29..38]
    ): [email protected]<41..47> = 
      [email protected]<50..51> :
        [email protected]<41..47>
      @Foo.scala<41..51>
    @Foo.scala[14..25..51]
    def foo: String = 
      /* inlined from 
        [email protected]<64..64>.fun@
          Foo.scala<64..67>
        ("abc"@Foo.scala<68..73>)@
          Foo.scala<64..74>
       */ 
        {
          "abc"@Foo.scala<50..51> :
            [email protected]<41..47>
          @Foo.scala<64..74>
        }
      @Foo.scala<64..74>
    @Foo.scala[54..58..74]
  }@Foo.scala[0..6..76]
}@Foo.scala<0..76>

We can see that the position before inlining was "abc"@Foo.scala<68..73> but after inlining it becomes "abc"@Foo.scala<50..51> which is the position of the x in the body of fun.

#6024 will add a way to test these positions.

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