Skip to content

Commit 0776643

Browse files
committed
Add test files and make tests working
1 parent 0daf178 commit 0776643

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,9 +4064,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
40644064
case wtp: ExprType =>
40654065
readaptSimplified(tree.withType(wtp.resultType))
40664066
case wtp: MethodType if wtp.isImplicitMethod &&
4067-
ctx.mode.is(Mode.ImplicitsEnabled) &&
4068-
({ resMatch = constrainResult(tree.symbol, wtp, sharpenedPt); resMatch } || !functionExpected) =>
4069-
if (resMatch)
4067+
({ resMatch = constrainResult(tree.symbol, wtp, sharpenedPt); resMatch } || !functionExpected) &&
4068+
((resMatch && !ctx.mode.is(Mode.QuotedPattern)) || !resMatch) =>
4069+
if (resMatch || ctx.mode.is(Mode.ImplicitsEnabled))
40704070
adaptNoArgsImplicitMethod(wtp)
40714071
else
40724072
// Don't proceed with implicit search if result type cannot match - the search

tests/run-macros/i17905.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
case 1: [3rd case] another_given outside
2+
case 2: [3rd case] given outside

tests/run-macros/i17905/Macro_1.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import scala.quoted.*
2+
3+
inline def testCtxParam(inline body: Any) = ${ testCtxParamImpl('body) }
4+
def testCtxParamImpl(body: Expr[Any])(using Quotes): Expr[String] =
5+
body match
6+
case '{ given i: String = "given"; def g(using s: String) = "placeholder"; $a(g, i): String } =>
7+
'{ $a(((s: String) ?=> s"[3rd case] ${s}"), "another_given") }
8+
case '{ def g(using s: String) = "placeholder"; $a(g): String } =>
9+
'{ $a((s: String) ?=> s"[3rd case] ${s}") }
10+
case _ => Expr("not matched")

tests/run-macros/i17905/Test_2.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@main def Test: Unit =
2+
println("case 1: " + testCtxParam { given String = "given"; def f(using t: String) = "placeholder"; f + " outside" })
3+
given String = "given"
4+
println("case 2: " + testCtxParam { def f(using t: String) = "placeholder"; f + " outside" })

0 commit comments

Comments
 (0)