Skip to content

Commit 823f17b

Browse files
committed
Cleanup TreeChecker adapt assertion message
The "infoStr" I felt caused more noise and confusion, so I remove it. I also pushed the type mismatch message done 1 line, so it displays better multi-line (the "Found" and "Required" are alined).
1 parent 6345210 commit 823f17b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,23 +744,16 @@ object TreeChecker {
744744
override def adapt(tree: Tree, pt: Type, locked: TypeVars)(using Context): Tree = {
745745
def isPrimaryConstructorReturn =
746746
ctx.owner.isPrimaryConstructor && pt.isRef(ctx.owner.owner) && tree.tpe.isRef(defn.UnitClass)
747-
def infoStr(tp: Type) = tp match {
748-
case tp: TypeRef =>
749-
val sym = tp.symbol
750-
i"${sym.showLocated} with ${tp.designator}, flags = ${sym.flagsString}, underlying = ${tp.underlyingIterator.toList}%, %"
751-
case _ =>
752-
"??"
753-
}
754-
if (ctx.mode.isExpr &&
755-
!tree.isEmpty &&
756-
!isPrimaryConstructorReturn &&
757-
!pt.isInstanceOf[FunOrPolyProto])
747+
if ctx.mode.isExpr
748+
&& !tree.isEmpty
749+
&& !isPrimaryConstructorReturn
750+
&& !pt.isInstanceOf[FunOrPolyProto]
751+
then
758752
assert(tree.tpe <:< pt, {
759753
val mismatch = TypeMismatch(tree.tpe, pt, Some(tree))
760-
i"""|${mismatch.msg}
761-
|found: ${infoStr(tree.tpe)}
762-
|expected: ${infoStr(pt)}
763-
|tree = $tree""".stripMargin
754+
i"""|Type Mismatch:
755+
|${mismatch.message}
756+
|tree = $tree ${tree.className}""".stripMargin
764757
})
765758
tree
766759
}

0 commit comments

Comments
 (0)