Skip to content

Commit e4d5057

Browse files
committed
Remove unnecessary type from UnApply
This type is never used, it is just a placeholder to make the tree typed. It is the `Typed` tree around the `UnApply` that holds the type information.
1 parent 3dd15f7 commit e4d5057

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
197197
def Alternative(trees: List[Tree])(using Context): Alternative =
198198
ta.assignType(untpd.Alternative(trees), trees)
199199

200-
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(using Context): UnApply = {
200+
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree])(using Context): UnApply = {
201201
assert(fun.isInstanceOf[RefTree] || fun.isInstanceOf[GenericApply])
202-
ta.assignType(untpd.UnApply(fun, implicits, patterns), proto)
202+
ta.assignType(untpd.UnApply(fun, implicits, patterns), defn.NothingType)
203203
}
204204

205205
def ValDef(sym: TermSymbol, rhs: LazyTree = EmptyTree)(using Context): ValDef =

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ class TreePickler(pickler: TastyPickler) {
538538
writeByte(IMPLICITarg)
539539
pickleTree(implicitArg)
540540
}
541-
pickleType(tree.tpe)
541+
// TODO write a dummy type that takes less space?
542+
pickleType(tree.tpe) // IGNORED // TODO remove when we can break TASTy compat.
542543
patterns.foreach(pickleTree)
543544
}
544545
case tree: ValDef =>

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,9 @@ class TreeUnpickler(reader: TastyReader,
12481248
readByte()
12491249
readTerm()
12501250
}
1251-
val patType = readType()
1251+
val patType = readType() // IGNORED // TODO remove when we can break TASTy compat.
12521252
val argPats = until(end)(readTerm())
1253-
UnApply(fn, implicitArgs, argPats, patType)
1253+
UnApply(fn, implicitArgs, argPats)
12541254
case REFINEDtpt =>
12551255
val refineCls = symAtAddr.getOrElse(start,
12561256
newRefinedClassSymbol(coordAt(start))).asClass

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
11751175
case UNAPPLYtree =>
11761176
val fun = readTreeRef()
11771177
val args = until(end, () => readTreeRef())
1178-
UnApply(fun, Nil, args, defn.AnyType) // !!! this is wrong in general
1178+
UnApply(fun, Nil, args)
11791179

11801180
case ARRAYVALUEtree =>
11811181
val elemtpt = readTreeRef()

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,11 @@ trait QuotesAndSplices {
469469
val matchModule = if tree.quoted.isTerm then defn.QuoteMatching_ExprMatch else defn.QuoteMatching_TypeMatch
470470
val unapplyFun = qctx.asInstance(defn.QuoteMatchingClass.typeRef).select(matchModule).select(nme.unapply)
471471

472-
UnApply(
473-
fun = unapplyFun.appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
474-
implicits = quotedPattern :: Nil,
475-
patterns = splicePat :: Nil,
476-
proto = quoteClass.typeRef.appliedTo(replaceBindings(quoted1.tpe) & quotedPt))
472+
Typed(
473+
UnApply(
474+
fun = unapplyFun.appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
475+
implicits = quotedPattern :: Nil,
476+
patterns = splicePat :: Nil),
477+
TypeTree(quoteClass.typeRef.appliedTo(replaceBindings(quoted1.tpe) & quotedPt)))
477478
}
478479
}

0 commit comments

Comments
 (0)