Skip to content

Commit ac3c430

Browse files
committed
Fix #6142: remove unreasonable type change for _
The logic was introduced in f618e47, which is hard to justify. The problem is exhibited in tests/pos/i6142.scala, where we have code lik the following: implicit val _: scala.quoted.Type = ... { def $anon$ = _ closure($anon$) } Changing the type of `_` will break LambdLift (`_` is not free anymore), and the compiler crashes at backend when generating code for the unfound local variable `_`, whose symbol is `scala.quoted.Type`.
1 parent 671aa3a commit ac3c430

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,7 @@ object Erasure {
614614
if (sym.isConstructor) defn.UnitType
615615
else sym.info.resultType
616616
var vparamss1 = (outer.paramDefs(sym) ::: ddef.vparamss.flatten) :: Nil
617-
var rhs1 = ddef.rhs match {
618-
case id @ Ident(nme.WILDCARD) => untpd.TypedSplice(id.withType(restpe))
619-
case _ => ddef.rhs
620-
}
617+
var rhs1 = ddef.rhs
621618
if (sym.isAnonymousFunction && vparamss1.head.length > MaxImplementedFunctionArity) {
622619
val bunchedParam = ctx.newSymbol(sym, nme.ALLARGS, Flags.TermParam, JavaArrayType(defn.ObjectType))
623620
def selector(n: Int) = ref(bunchedParam)

tests/pos/i6142.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+
object O {
4+
def foo given QuoteContext = {
5+
type T
6+
implicit val _: scala.quoted.Type[T] = ???
7+
'[List[T]]
8+
()
9+
}
10+
}

0 commit comments

Comments
 (0)