diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-14 13:04:17 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-14 13:04:17 +0100 |
commit | 550bf861e28a62a5057d6816e0bd336463e9b0bf (patch) | |
tree | 83ddab03850fcd54a4ab141b8695cbbc30f8634b | |
parent | 38b87f4b33ea0b0a1add120d49d252ffe6582ccd (diff) | |
download | dotty-550bf861e28a62a5057d6816e0bd336463e9b0bf.tar.gz dotty-550bf861e28a62a5057d6816e0bd336463e9b0bf.tar.bz2 dotty-550bf861e28a62a5057d6816e0bd336463e9b0bf.zip |
Better error message for double definitions.
If one of the conflicting definitions is synthetic, it will now point to the code position of the other.
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index ae7334513..cfcf882f4 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -398,11 +398,15 @@ object Inferencing { for (other <- seen(decl.name)) { typr.println(i"conflict? $decl $other") if (decl.signature matches other.signature) { - val ofType = if (decl.isType) "" else i": ${other.info}" - val explanation = - if (!decl.isSourceMethod) "" - else "\n (both definitions have the same erased type signature)" - ctx.error(i"$decl is already defined as $other$ofType$explanation", decl.pos) + def doubleDefError(decl: Symbol, other: Symbol): Unit = { + val ofType = if (decl.isType) "" else i": ${other.info}" + val explanation = + if (!decl.isSourceMethod) "" + else "\n (both definitions have the same erased type signature)" + ctx.error(i"$decl is already defined as $other$ofType$explanation", decl.pos) + } + if (decl is Synthetic) doubleDefError(other, decl) + else doubleDefError(decl, other) } } seen(decl.name) = decl :: seen(decl.name) |