From 03e4ab360a62a76283930fcf9a3ecec74133a98b Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Fri, 2 Mar 2018 22:20:35 +0100 Subject: [PATCH 01/11] Add error message about double definition (#1589) --- .../reporting/diagnostic/ErrorMessageID.java | 1 + .../dotc/reporting/diagnostic/messages.scala | 6 ++++++ .../src/dotty/tools/dotc/typer/Checking.scala | 2 +- .../dotc/reporting/ErrorMessagesTests.scala | 21 +++++++++++++++---- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java index a387877f563a..738ce14a2771 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java @@ -127,6 +127,7 @@ public enum ErrorMessageID { PolymorphicMethodMissingTypeInParentID, ParamsNoInlineID, JavaSymbolIsNotAValueID, + DoubleDeclarationID, ; public int errorNumber() { diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 00f5f76874d3..3cba6a8d5781 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2079,4 +2079,10 @@ object messages { } val explanation = "" } + + case class DoubleDeclaration(decl: Symbol, previousSymbol: Symbol)(implicit ctx: Context) extends Message(DoubleDeclarationID) { + val kind = "Duplicate Symbol" + val msg = hl"$decl is already defined as $previousSymbol${previousSymbol.showExtendedLocation}" + val explanation = "" + } } diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 828da5d007da..fb6d61e0fc8f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -627,7 +627,7 @@ trait Checking { def explanation = if (!decl.isRealMethod) "" else "\n(the definitions have matching type signatures)" - ctx.error(em"$decl is already defined as $other$ofType$explanation", decl.pos) + ctx.error(DoubleDeclaration(decl, other), decl.pos) } if (decl is Synthetic) doubleDefError(other, decl) else doubleDefError(decl, other) diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala index 25f1e8868c93..96f6c55ce501 100644 --- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala +++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala @@ -2,12 +2,10 @@ package dotty.tools package dotc package reporting -import core.Contexts.Context -import diagnostic.messages._ -import dotty.tools.dotc.core.Flags -import dotty.tools.dotc.core.Flags.FlagSet +import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Types.WildcardType import dotty.tools.dotc.parsing.Tokens +import dotty.tools.dotc.reporting.diagnostic.messages._ import org.junit.Assert._ import org.junit.Test @@ -1293,4 +1291,19 @@ class ErrorMessagesTests extends ErrorMessagesTest { assert(ctx.reporter.hasErrors) } + + @Test def typeDoubleDeclaration = + checkMessagesAfter("frontend") { + """ + |class Foo { + | val a = 1 + | val a = 2 + |} + """.stripMargin + }.expect { (ictx, messages) => + implicit val ctx: Context = ictx + assertMessageCount(1, messages) + val DoubleDeclaration(symbol, previousSymbol) :: Nil = messages + assertEquals(symbol.name.mangledString, "a") + } } From 06c7a5186f60209a2c9a7123821c8958f022b147 Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sat, 3 Mar 2018 13:56:53 +0100 Subject: [PATCH 02/11] remove unused methods --- compiler/src/dotty/tools/dotc/typer/Checking.scala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index fb6d61e0fc8f..6e1a5242fa66 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -623,10 +623,6 @@ trait Checking { typr.println(i"conflict? $decl $other") if (decl.matches(other)) { def doubleDefError(decl: Symbol, other: Symbol): Unit = { - def ofType = if (decl.isType) "" else em": ${other.info}" - def explanation = - if (!decl.isRealMethod) "" - else "\n(the definitions have matching type signatures)" ctx.error(DoubleDeclaration(decl, other), decl.pos) } if (decl is Synthetic) doubleDefError(other, decl) From d4455fd50e312ef5fb946da74bba31f0b6d505db Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sat, 3 Mar 2018 14:17:39 +0100 Subject: [PATCH 03/11] fix error counts for tests/neg/singletonOrs --- tests/neg/singletonOrs.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/neg/singletonOrs.scala b/tests/neg/singletonOrs.scala index 687e491ef7a1..7bcfa7967f57 100644 --- a/tests/neg/singletonOrs.scala +++ b/tests/neg/singletonOrs.scala @@ -1,6 +1,6 @@ object Test { def foo: 1 | 2 = 1 // error // error def bar: 3 | 4 = foo // error // error - def foo: 1 | 2 = 1 // error // error - def bar: 1 = foo + def foo: 1 | 2 = 1 // error // error // error + def bar: 1 = foo // error } From aa9ce63220e47d4a95a95bee9d21db8411f42a0f Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sat, 10 Mar 2018 00:31:36 +0100 Subject: [PATCH 04/11] WIP try to improve error messages --- .../dotc/reporting/diagnostic/messages.scala | 9 +++++- tests/neg/doubleDefinition.scala | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/neg/doubleDefinition.scala diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 3cba6a8d5781..31ce3f061c11 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2082,7 +2082,14 @@ object messages { case class DoubleDeclaration(decl: Symbol, previousSymbol: Symbol)(implicit ctx: Context) extends Message(DoubleDeclarationID) { val kind = "Duplicate Symbol" - val msg = hl"$decl is already defined as $previousSymbol${previousSymbol.showExtendedLocation}" + val msg = { + val details = decl.asTerm.signature.matchDegree(previousSymbol.asTerm.signature) match { + case Signature.NoMatch => "" // matchDegree also returns NoMatch if one of the terms is not a method + case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." + case Signature.FullMatch => "\nThe definitions have the same signature after erasure." + } + hl"${decl.showLocated} is already defined as ${previousSymbol.showDcl} in line ${previousSymbol.pos.line}." + details + } val explanation = "" } } diff --git a/tests/neg/doubleDefinition.scala b/tests/neg/doubleDefinition.scala new file mode 100644 index 000000000000..57f41f045865 --- /dev/null +++ b/tests/neg/doubleDefinition.scala @@ -0,0 +1,29 @@ +trait A +trait B + +class Test1 { + def foo(x: List[A]): Function1[A, A] = ??? + def foo(x: List[B]): Function2[B, B, B] = ??? + // ok, different jvm signature +} + + +class Test2 { + + + + def foo( + x: List[A] + ): Function1[A, + A] = + ??? + def foo(x: List[B]): Function1[B, B] = ??? // error: same jvm signature + // scalac calls this "have same type after erasure" +} + + +class Test3 { + // overload with same argument type, but different return types + def foo(x: List[A]): Function1[A, A] = ??? + def foo(x: List[A]): Function2[B, B, B] = ??? // error +} From aa803ed8994f704eb3e22868b8f5b1704587299a Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 01:19:30 +0100 Subject: [PATCH 05/11] fix off by one error when printing line of previously declared symbol --- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 2 +- tests/neg/doubleDefinition.scala | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 31ce3f061c11..7fee949ef646 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2088,7 +2088,7 @@ object messages { case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." case Signature.FullMatch => "\nThe definitions have the same signature after erasure." } - hl"${decl.showLocated} is already defined as ${previousSymbol.showDcl} in line ${previousSymbol.pos.line}." + details + hl"${decl.showLocated} is already defined as ${previousSymbol.showDcl} in line ${previousSymbol.pos.line + 1}." + details } val explanation = "" } diff --git a/tests/neg/doubleDefinition.scala b/tests/neg/doubleDefinition.scala index 57f41f045865..531a73ff8fe4 100644 --- a/tests/neg/doubleDefinition.scala +++ b/tests/neg/doubleDefinition.scala @@ -9,14 +9,7 @@ class Test1 { class Test2 { - - - - def foo( - x: List[A] - ): Function1[A, - A] = - ??? + def foo(x: List[A]): Function1[A, A] = ??? def foo(x: List[B]): Function1[B, B] = ??? // error: same jvm signature // scalac calls this "have same type after erasure" } From 68dcdec61f61cb94b6d73737ac3a6bb501f9e3ce Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 01:22:23 +0100 Subject: [PATCH 06/11] don't show error about signatures when a var/val and a def are clashing --- .../dotc/reporting/diagnostic/messages.scala | 13 ++- tests/neg/doubleDefinition.scala | 108 +++++++++++++++++- 2 files changed, 114 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 7fee949ef646..43a6fb1b007a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2083,11 +2083,14 @@ object messages { case class DoubleDeclaration(decl: Symbol, previousSymbol: Symbol)(implicit ctx: Context) extends Message(DoubleDeclarationID) { val kind = "Duplicate Symbol" val msg = { - val details = decl.asTerm.signature.matchDegree(previousSymbol.asTerm.signature) match { - case Signature.NoMatch => "" // matchDegree also returns NoMatch if one of the terms is not a method - case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." - case Signature.FullMatch => "\nThe definitions have the same signature after erasure." - } + val details = if (decl.isRealMethod && previousSymbol.isRealMethod) { + // compare the signatures when both symbols represent methods + decl.asTerm.signature.matchDegree(previousSymbol.asTerm.signature) match { + case Signature.NoMatch => "" + case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." + case Signature.FullMatch => "\nThe definitions have the same signature after erasure." + } + } else "" hl"${decl.showLocated} is already defined as ${previousSymbol.showDcl} in line ${previousSymbol.pos.line + 1}." + details } val explanation = "" diff --git a/tests/neg/doubleDefinition.scala b/tests/neg/doubleDefinition.scala index 531a73ff8fe4..94ebac4f448c 100644 --- a/tests/neg/doubleDefinition.scala +++ b/tests/neg/doubleDefinition.scala @@ -1,22 +1,126 @@ trait A trait B +// test with classes + class Test1 { def foo(x: List[A]): Function1[A, A] = ??? def foo(x: List[B]): Function2[B, B, B] = ??? // ok, different jvm signature } - class Test2 { def foo(x: List[A]): Function1[A, A] = ??? def foo(x: List[B]): Function1[B, B] = ??? // error: same jvm signature // scalac calls this "have same type after erasure" } - class Test3 { // overload with same argument type, but different return types def foo(x: List[A]): Function1[A, A] = ??? def foo(x: List[A]): Function2[B, B, B] = ??? // error } + +class Test4 { + val foo = 1 + def foo = 2 // error +} + +class Test4b { + def foo = 2 + val foo = 1 // error +} + +class Test4c { + def foo = 2 + var foo = 1 // error +} + +class Test4d { + var foo = 1 + def foo = 2 // error +} + + +// test with traits + +trait Test5 { + def foo(x: List[A]): Function1[A, A] = ??? + def foo(x: List[B]): Function2[B, B, B] = ??? + // ok, different jvm signature +} + +trait Test6 { + def foo(x: List[A]): Function1[A, A] = ??? + def foo(x: List[B]): Function1[B, B] = ??? // error: same jvm signature + // scalac calls this "have same type after erasure" +} + +trait Test7 { + // overload with same argument type, but different return types + def foo(x: List[A]): Function1[A, A] = ??? + def foo(x: List[A]): Function2[B, B, B] = ??? // error +} + +class Test8 { + val foo = 1 + def foo = 2 // error +} + +class Test8b { + def foo = 2 + val foo = 1 // error +} + +class Test8c { + def foo = 2 + var foo = 1 // error +} + +class Test8d { + var foo = 1 + def foo = 2 // error +} + +// test method and contructor argument clashing + +class Test9(val foo: Int) { + def foo: String // error +} + +class Test10(val foo: Int) { + def foo: Int // error +} + +abstract class Test11(val foo: Int) { + def foo: String // error +} + +abstract class Test12(val foo: Int) { + def foo: Int // error +} + +class Test13(var foo: Int) { + def foo: String // error +} + +class Test14(var foo: Int) { + def foo: Int // error +} + +abstract class Test15(var foo: Int) { + def foo: String // error +} + +abstract class Test16(var foo: Int) { + def foo: Int // error +} + +// don't error when shadowing + +class Test17 { + val foo = 1 + def bar() = { + val foo = "" + } +} From 4df133e6b285bc5345c8e84ed91a34983b207bac Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 01:35:42 +0100 Subject: [PATCH 07/11] call it declaration consistently --- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 8 ++++---- compiler/src/dotty/tools/dotc/typer/Checking.scala | 8 ++++---- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 43a6fb1b007a..2fe1f3284cc6 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2080,18 +2080,18 @@ object messages { val explanation = "" } - case class DoubleDeclaration(decl: Symbol, previousSymbol: Symbol)(implicit ctx: Context) extends Message(DoubleDeclarationID) { + case class DoubleDeclaration(decl: Symbol, previousDecl: Symbol)(implicit ctx: Context) extends Message(DoubleDeclarationID) { val kind = "Duplicate Symbol" val msg = { - val details = if (decl.isRealMethod && previousSymbol.isRealMethod) { + val details = if (decl.isRealMethod && previousDecl.isRealMethod) { // compare the signatures when both symbols represent methods - decl.asTerm.signature.matchDegree(previousSymbol.asTerm.signature) match { + decl.asTerm.signature.matchDegree(previousDecl.asTerm.signature) match { case Signature.NoMatch => "" case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." case Signature.FullMatch => "\nThe definitions have the same signature after erasure." } } else "" - hl"${decl.showLocated} is already defined as ${previousSymbol.showDcl} in line ${previousSymbol.pos.line + 1}." + details + hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} in line ${previousDecl.pos.line + 1}." + details } val explanation = "" } diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 6e1a5242fa66..9046e93b68ef 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -611,12 +611,12 @@ trait Checking { } } - /** Check that class does not define same symbol twice */ - def checkNoDoubleDefs(cls: Symbol)(implicit ctx: Context): Unit = { + /** Check that class does not declare same symbol twice */ + def checkNoDoubleDeclaration(cls: Symbol)(implicit ctx: Context): Unit = { val seen = new mutable.HashMap[Name, List[Symbol]] { override def default(key: Name) = Nil } - typr.println(i"check no double defs $cls") + typr.println(i"check no double declarations $cls") def checkDecl(decl: Symbol): Unit = { for (other <- seen(decl.name)) { @@ -866,7 +866,7 @@ trait NoChecking extends ReChecking { override def checkImplicitParamsNotSingletons(vparamss: List[List[ValDef]])(implicit ctx: Context): Unit = () override def checkFeasibleParent(tp: Type, pos: Position, where: => String = "")(implicit ctx: Context): Type = tp override def checkInlineConformant(tree: Tree, what: => String)(implicit ctx: Context) = () - override def checkNoDoubleDefs(cls: Symbol)(implicit ctx: Context): Unit = () + override def checkNoDoubleDeclaration(cls: Symbol)(implicit ctx: Context): Unit = () override def checkParentCall(call: Tree, caller: ClassSymbol)(implicit ctx: Context) = () override def checkSimpleKinded(tpt: Tree)(implicit ctx: Context): Tree = tpt override def checkNotSingleton(tpt: Tree, where: String)(implicit ctx: Context): Tree = tpt diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 9387a89311e7..a0c6af3deb1e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1506,7 +1506,7 @@ class Typer extends Namer // Expand comments and type usecases cookComments(body1.map(_.symbol), self1.symbol)(ctx.localContext(cdef, cls).setNewScope) - checkNoDoubleDefs(cls) + checkNoDoubleDeclaration(cls) val impl1 = cpy.Template(impl)(constr1, parents1, self1, body1) .withType(dummy.termRef) checkVariance(impl1) From b6e1090eff221a9db960876e2702eebb65eac1f7 Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 22:44:16 +0100 Subject: [PATCH 08/11] remove Signature.NoMatch from cases because it should not happen --- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 4 ++-- tests/neg/doubleDefinition.scala | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 2fe1f3284cc6..3387a669e1ac 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2086,9 +2086,9 @@ object messages { val details = if (decl.isRealMethod && previousDecl.isRealMethod) { // compare the signatures when both symbols represent methods decl.asTerm.signature.matchDegree(previousDecl.asTerm.signature) match { - case Signature.NoMatch => "" + /* case Signature.NoMatch => // can't happen because decl.matches(previousDecl) is checked before reporting this error */ case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." - case Signature.FullMatch => "\nThe definitions have the same signature after erasure." + case _ /* Signature.FullMatch */ => "\nThe definitions have the same signature after erasure." } } else "" hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} in line ${previousDecl.pos.line + 1}." + details diff --git a/tests/neg/doubleDefinition.scala b/tests/neg/doubleDefinition.scala index 94ebac4f448c..32ce239e3b43 100644 --- a/tests/neg/doubleDefinition.scala +++ b/tests/neg/doubleDefinition.scala @@ -124,3 +124,10 @@ class Test17 { val foo = "" } } + +// no error when overloading + +class Test18 { + def foo(a: A) = 1 + def foo(b: B) = 1 +} From 5672fcf6aa6e729e4c208723b6153cb16d58cc3f Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 22:50:42 +0100 Subject: [PATCH 09/11] remove redundant asTerm --- .../src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 3387a669e1ac..64176ae9fb57 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2085,7 +2085,7 @@ object messages { val msg = { val details = if (decl.isRealMethod && previousDecl.isRealMethod) { // compare the signatures when both symbols represent methods - decl.asTerm.signature.matchDegree(previousDecl.asTerm.signature) match { + decl.signature.matchDegree(previousDecl.signature) match { /* case Signature.NoMatch => // can't happen because decl.matches(previousDecl) is checked before reporting this error */ case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." case _ /* Signature.FullMatch */ => "\nThe definitions have the same signature after erasure." From c569c8aa978ff75f187ed0c5d5ed6ea60312b4ce Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Sun, 11 Mar 2018 22:52:32 +0100 Subject: [PATCH 10/11] fix grammar and wording --- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 64176ae9fb57..50e2afd6a9ed 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -2087,11 +2087,11 @@ object messages { // compare the signatures when both symbols represent methods decl.signature.matchDegree(previousDecl.signature) match { /* case Signature.NoMatch => // can't happen because decl.matches(previousDecl) is checked before reporting this error */ - case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed." - case _ /* Signature.FullMatch */ => "\nThe definitions have the same signature after erasure." + case Signature.ParamMatch => "\nOverloads with matching parameter types are not allowed." + case _ /* Signature.FullMatch */ => "\nThe definitions have matching type signatures after erasure." } } else "" - hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} in line ${previousDecl.pos.line + 1}." + details + hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} at line ${previousDecl.pos.line + 1}." + details } val explanation = "" } From e4c64b7ee3774a5867bcb6bf8d6666c655fadb00 Mon Sep 17 00:00:00 2001 From: Jendrik Wenke Date: Mon, 12 Mar 2018 15:19:11 +0100 Subject: [PATCH 11/11] remove double definition in singletonOr test --- tests/neg/singletonOrs.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/neg/singletonOrs.scala b/tests/neg/singletonOrs.scala index 7bcfa7967f57..3bf103d68815 100644 --- a/tests/neg/singletonOrs.scala +++ b/tests/neg/singletonOrs.scala @@ -1,6 +1,6 @@ object Test { - def foo: 1 | 2 = 1 // error // error - def bar: 3 | 4 = foo // error // error - def foo: 1 | 2 = 1 // error // error // error - def bar: 1 = foo // error + def a: 1 | 2 = 1 // error // error + def b: 3 | 4 = a // error // error + def c: 1 | 2 = 1 // error // error + def d: 1 = a }