Skip to content

Commit b601d1b

Browse files
committed
Show resulting type when tracing "adapt" calls
1 parent e1f7af3 commit b601d1b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,16 +1800,17 @@ class Typer extends Namer
18001800
typed(ifun, pt)
18011801
}
18021802

1803-
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ trace(i"typing $tree", typr, show = true) /*<|<*/ {
1804-
record(s"typed $getClass")
1805-
record("typed total")
1806-
assertPositioned(tree)
1807-
try adapt(typedUnadapted(tree, pt), pt)
1808-
catch {
1809-
case ex: CyclicReference => errorTree(tree, cyclicErrorMsg(ex))
1810-
case ex: TypeError => errorTree(tree, ex.getMessage)
1803+
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree =
1804+
trace(i"typing $tree", typr, show = true) {
1805+
record(s"typed $getClass")
1806+
record("typed total")
1807+
assertPositioned(tree)
1808+
try adapt(typedUnadapted(tree, pt), pt)
1809+
catch {
1810+
case ex: CyclicReference => errorTree(tree, cyclicErrorMsg(ex))
1811+
case ex: TypeError => errorTree(tree, ex.getMessage)
1812+
}
18111813
}
1812-
}
18131814

18141815
def typedTrees(trees: List[untpd.Tree])(implicit ctx: Context): List[Tree] =
18151816
trees mapconserve (typed(_))
@@ -1977,7 +1978,11 @@ class Typer extends Namer
19771978
}
19781979

19791980
def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = /*>|>*/ track("adapt") /*<|<*/ {
1980-
/*>|>*/ trace(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ {
1981+
def showWithType(x: Any) = x match {
1982+
case tree: tpd.Tree @unchecked => i"$tree of type ${tree.tpe}"
1983+
case _ => String.valueOf(x)
1984+
}
1985+
/*>|>*/ trace(i"adapting $tree of type ${tree.tpe} to $pt", typr, showOp = showWithType) /*<|<*/ {
19811986
if (!tree.denot.isOverloaded) {
19821987
// for overloaded trees: resolve overloading before simplifying
19831988
if (tree.isDef) interpolateUndetVars(tree, tree.symbol, pt)

0 commit comments

Comments
 (0)