From 24dcb0c14897387b6ae6387a664216f500548672 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Wed, 29 May 2019 11:51:50 +0200 Subject: [PATCH] Improve debuggability for compiler crash when using tasty reflect Without the change, we get an error message like the following: ``` 1 |def test(x: Int) = foo(x) | ^^^^^^ |An exception occurred while executing macro expansion |assertion failed: no overloads available for > on Int with targs: ; args: x of types rhsTpe$_$1(x); expectedType: ?.all alternatives: def >(x: Double): Boolean, def >(x: Float): Boolean, def >(x: Long): Boolean, def >(x: Int): Boolean, def >(x: Char): Boolean, def >(x: Short): Boolean, def >(x: Byte): Boolean ``` With the change, mysterious type `rhsTpe$_$1(x)` is replaced with the type `String`. --- compiler/src/dotty/tools/dotc/ast/tpd.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 618ea8cdacdd..365dac55f80e 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -1129,7 +1129,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { val alternatives = ctx.typer.resolveOverloaded(allAlts, proto) assert(alternatives.size == 1, i"${if (alternatives.isEmpty) "no" else "multiple"} overloads available for " + - i"$method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, % of types ${args.tpes}%, %; expectedType: $expectedType." + + i"$method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, % of types ${args.tpes.map(_.widenDealiasKeepAnnots)}%, %; expectedType: $expectedType." + i"all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(", ")}\n" + i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it alternatives.head