Skip to content

Fix quoted patterns with references to private fields #15838

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
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait QuotesAndSplices {
report.error(em"Quotes require stable Quotes, but found non stable $quotes", quotes.srcPos)

if ctx.mode.is(Mode.Pattern) then
typedQuotePattern(tree, pt, quotes).withSpan(tree.span)
PrepareInlineable.makeInlineable(typedQuotePattern(tree, pt, quotes).withSpan(tree.span))
else if tree.isTypeQuote then
val msg = em"""Quoted types `'[..]` can only be used in patterns.
|
Expand Down
14 changes: 14 additions & 0 deletions tests/pos-macros/i15676/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package foo

import scala.quoted.*

private[foo] object Foo:
def apply(): Int = ???

inline def test(): Unit = ${ testExpr() }

private def testExpr()(using Quotes): Expr[Unit] = {
'{ Foo() } match
case '{ Foo() } =>
'{}
}
1 change: 1 addition & 0 deletions tests/pos-macros/i15676/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def Test() = foo.test()