Skip to content

Commit 8767f8e

Browse files
committed
Fix quoted match inline bindings leak
And make `inlineContext` resilient to previous errors (i.e. never add an empty call).
1 parent 6948038 commit 8767f8e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,12 +1234,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12341234
override def inlineContext(call: Tree)(implicit ctx: Context): Context = {
12351235
// We assume enclosingInlineds is already normalized, and only process the new call with the head.
12361236
val oldIC = enclosingInlineds
1237-
val newIC = (call, oldIC) match {
1238-
case (t, t1 :: ts2) if t.isEmpty =>
1239-
assert(!t1.isEmpty)
1240-
ts2
1241-
case _ => call :: oldIC
1242-
}
1237+
1238+
val newIC =
1239+
if call.isEmpty then
1240+
oldIC match
1241+
case t1 :: ts2 => ts2
1242+
case _ => oldIC
1243+
else
1244+
call :: oldIC
1245+
12431246
ctx.fresh.setProperty(InlinedCalls, newIC)
12441247
}
12451248

library/src/scala/internal/quoted/Matcher.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private[quoted] object Matcher {
3333
if (hasTypeSplices) {
3434
val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext)
3535
given Context = ctx
36-
val matchings = scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument
36+
val matchings = scrutineeTerm =?= patternTerm
3737
// After matching and doing all subtype checks, we have to approximate all the type bindings
3838
// that we have found and seal them in a quoted.Type
3939
matchings.asOptionOfTuple.map { tup =>
@@ -44,7 +44,7 @@ private[quoted] object Matcher {
4444
}
4545
}
4646
else {
47-
scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument
47+
scrutineeTerm =?= patternTerm
4848
}
4949
}
5050

@@ -286,6 +286,9 @@ private[quoted] object Matcher {
286286
case (_, Annotated(tpt, _)) =>
287287
scrutinee =?= tpt
288288

289+
case (NamedArg(name1, arg1), NamedArg(name2, arg2)) if name1 == name2 =>
290+
arg1 =?= arg2
291+
289292
// No Match
290293
case _ =>
291294
if (debug)

0 commit comments

Comments
 (0)