Skip to content

Commit

Permalink
Fix quoted pattens with references to private fields
Browse files Browse the repository at this point in the history
Reverts 0b072d6

Fixes scala#15676
  • Loading branch information
Nicolas Stucki committed Aug 9, 2022
1 parent e560c2d commit dbb0848
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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 @@ -49,7 +49,7 @@ trait QuotesAndSplices {
report.error(em"Quotes require stable Quotes, but found non stable $qctx", qctx.srcPos)

if ctx.mode.is(Mode.Pattern) then
typedQuotePattern(tree, pt, qctx).withSpan(tree.span)
makeInlineable(typedQuotePattern(tree, pt, qctx).withSpan(tree.span))
else if tree.quoted.isType 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()

0 comments on commit dbb0848

Please sign in to comment.