Skip to content

Fix #6803: Add regression test #8120

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

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/run-macros/i6803/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package blah

import scala.language.implicitConversions
import scala.quoted._

object AsObject {
final class LineNo(val lineNo: Int)
object LineNo {
def unsafe(i: Int): LineNo = new LineNo(i)
inline given LineNo = ${impl}
private def impl with (qctx: QuoteContext): Expr[LineNo] = {
import qctx.tasty.{given, _}
'{unsafe(${Expr(rootPosition.startLine)})}
}
}
}

package AsPackage {
final class LineNo(val lineNo: Int)
object LineNo {
def unsafe(i: Int): LineNo = new LineNo(i)
inline given LineNo = ${impl}
private def impl with (qctx: QuoteContext): Expr[LineNo] = {
import qctx.tasty.{given, _}
'{unsafe(${Expr(rootPosition.startLine)})}
}
}
}
15 changes: 15 additions & 0 deletions tests/run-macros/i6803/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import blah._

def testO(): Unit = {
import AsObject.LineNo
assert(summon[LineNo].lineNo == 4)
}

def testP(): Unit = {
import AsPackage.LineNo
assert(summon[LineNo].lineNo == 9)
}

@main def Test =
testO()
testP()