File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -4064,9 +4064,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4064
4064
case wtp : ExprType =>
4065
4065
readaptSimplified(tree.withType(wtp.resultType))
4066
4066
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 ) )
4070
4070
adaptNoArgsImplicitMethod(wtp)
4071
4071
else
4072
4072
// Don't proceed with implicit search if result type cannot match - the search
Original file line number Diff line number Diff line change
1
+ case 1: [3rd case] another_given outside
2
+ case 2: [3rd case] given outside
Original file line number Diff line number Diff line change
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" )
Original file line number Diff line number Diff line change
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" })
You can’t perform that action at this time.
0 commit comments