File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ object Mode {
44
44
/** Are we looking for cyclic references? */
45
45
val CheckCyclic : Mode = newMode(5 , " CheckCyclic" )
46
46
47
+ val InQuotePatternHoasArgs : Mode = newMode(6 , " InQuotePatternHoasArgs" )
48
+
47
49
/** We are in a pattern alternative */
48
50
val InPatternAlternative : Mode = newMode(7 , " InPatternAlternative" )
49
51
Original file line number Diff line number Diff line change @@ -107,12 +107,14 @@ trait QuotesAndSplices {
107
107
if isFullyDefined(pt, ForceDegree .flipBottom) then
108
108
def patternOuterContext (ctx : Context ): Context =
109
109
if (ctx.mode.is(Mode .QuotedPattern )) patternOuterContext(ctx.outer) else ctx
110
- val typedArgs = tree.args.map {
111
- case arg : untpd.Ident =>
112
- withoutMode(Mode .ImplicitsEnabled )(typedExpr(arg))
113
- case arg =>
114
- report.error(" Open pattern expected an identifier" , arg.srcPos)
115
- EmptyTree
110
+ val typedArgs = withMode(Mode .InQuotePatternHoasArgs ) {
111
+ tree.args.map {
112
+ case arg : untpd.Ident =>
113
+ typedExpr(arg)
114
+ case arg =>
115
+ report.error(" Open pattern expected an identifier" , arg.srcPos)
116
+ EmptyTree
117
+ }
116
118
}
117
119
for arg <- typedArgs if arg.symbol.is(Mutable ) do // TODO support these patterns. Possibly using scala.quoted.util.Var
118
120
report.error(" References to `var`s cannot be used in higher-order pattern" , arg.srcPos)
Original file line number Diff line number Diff line change @@ -4058,9 +4058,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4058
4058
wtp match {
4059
4059
case wtp : ExprType =>
4060
4060
readaptSimplified(tree.withType(wtp.resultType))
4061
- case wtp : MethodType if wtp.isImplicitMethod &&
4062
- ({ resMatch = constrainResult(tree.symbol, wtp, sharpenedPt); resMatch } || ! functionExpected) &&
4063
- ((resMatch && ! ctx.mode.is(Mode .QuotedPattern )) || ! resMatch) =>
4061
+ case wtp : MethodType
4062
+ if wtp.isImplicitMethod
4063
+ && ({ resMatch = constrainResult(tree.symbol, wtp, sharpenedPt); resMatch} || ! functionExpected)
4064
+ && ! ctx.mode.is(Mode .InQuotePatternHoasArgs ) =>
4064
4065
if (resMatch || ctx.mode.is(Mode .ImplicitsEnabled ))
4065
4066
adaptNoArgsImplicitMethod(wtp)
4066
4067
else
You can’t perform that action at this time.
0 commit comments