Skip to content

Commit 72a5f39

Browse files
oderskygzm0
authored andcommitted
Reverting decision what constitutes a double def.
test case t0273. Was positive in Scala 2, is now deemed to be negative. Two two definitions def a = () => () def a[T] = (p:A) => () do have matching signatures, so should constitute a double definition. I previously thought that we can get away if the two definitions have different result types, but then you immediately have a problem because the denotations have matching signatures for the pruposes of "&" yet cannot be merged. Which of the two definitions would override a definition in a base class is then an arbitrary decision.
1 parent 07939c9 commit 72a5f39

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ trait Checking extends NoChecking {
124124
for (decl <- cls.info.decls) {
125125
for (other <- seen(decl.name)) {
126126
typr.println(i"conflict? $decl $other")
127-
if (decl.signature == other.signature) {
127+
if (decl.signature matches other.signature) {
128128
def doubleDefError(decl: Symbol, other: Symbol): Unit = {
129129
def ofType = if (decl.isType) "" else i": ${other.info}"
130130
def explanation =

test/dotc/tests.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ class tests extends CompilerTest {
5353
@Test def neg_typedapply() = compileFile(negDir, "typedapply", xerrors = 4)
5454
@Test def neg_typedidents() = compileFile(negDir, "typedIdents", xerrors = 2)
5555
@Test def neg_assignments() = compileFile(negDir, "assignments", xerrors = 3)
56-
@Test def neg_typers() = compileFile(negDir, "typers", xerrors = 6)
56+
@Test def neg_typers() = compileFile(negDir, "typers", xerrors = 10)
5757
@Test def neg_privates() = compileFile(negDir, "privates", xerrors = 2)
5858
@Test def neg_rootImports = compileFile(negDir, "rootImplicits", xerrors = 2)
5959
@Test def neg_templateParents() = compileFile(negDir, "templateParents", xerrors = 3)
60-
@Test def neg_i39 = compileFile(negDir, "i39", xerrors = 1)
61-
@Test def neg_i50_volatile = compileFile(negDir, "i50-volatile", xerrors = 4)
62-
@Test def neg_companions = compileFile(negDir, "companions", xerrors = 1)
6360
@Test def neg_autoTupling = compileFile(posDir, "autoTuplingTest", "-language:noAutoTupling" :: Nil, xerrors = 3)
6461
@Test def neg_autoTupling2 = compileFile(negDir, "autoTuplingTest", xerrors = 3)
62+
@Test def neg_companions = compileFile(negDir, "companions", xerrors = 1)
63+
@Test def neg_i39 = compileFile(negDir, "i39", xerrors = 1)
64+
@Test def neg_i50_volatile = compileFile(negDir, "i50-volatile", xerrors = 4)
65+
@Test def neg_t0273_doubledefs = compileFile(negDir, "t0273", xerrors = 1)
6566
@Test def neg_t0654_polyalias = compileFile(negDir, "t0654", xerrors = 2)
6667
@Test def neg_t1192_legalPrefix = compileFile(negDir, "t1192", xerrors = 1)
6768

File renamed without changes.

tests/pos/overloaded.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ object overloaded {
22

33
def f(x: String): String = x
44
def f[T >: Null](x: T): Int = 1
5-
5+
66
val x1 = f("abc")
77
val x2 = f(new Integer(1))
88
val x3 = f(null)
9-
9+
1010
val x4: String => String = f
1111
val x5: String => Any = f
1212
val x6: Any = f _
13-
13+
1414
def g(): Int = 1
1515
def g(x: Int): Int = 2
16-
16+
1717
val y1: Int => Int = g
18-
val y2: Any = g _
19-
18+
val y2: Any = g _
19+
2020
println(g)
21-
21+
2222
val xs = List("a", "b")
2323
xs.mkString
2424
}

0 commit comments

Comments
 (0)