Skip to content

Commit 06bfbd3

Browse files
committed
Strengthen requirement for auto-tupling
Was: corresponding parameter types "are compatible". Now: corresponding parameter types "conform". This avoids the inconsistency mentioned by @retronym in #897.
1 parent e5f8697 commit 06bfbd3

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
618618
formal.derivesFrom(pclass) &&
619619
formal.baseArgTypes(pclass).corresponds(params) {
620620
(argType, param) =>
621-
param.tpt.isEmpty || isCompatible(argType, typedAheadType(param.tpt).tpe)
621+
param.tpt.isEmpty || argType <:< typedAheadType(param.tpt).tpe
622622
}
623623
}
624624

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class tests extends CompilerTest {
111111
@Test def neg_abstractOverride() = compileFile(negDir, "abstract-override", xerrors = 2)
112112
@Test def neg_blockescapes() = compileFile(negDir, "blockescapesNeg", xerrors = 1)
113113
@Test def neg_bounds() = compileFile(negDir, "bounds", xerrors = 2)
114-
@Test def neg_functionArity() = compileFile(negDir, "function-arity", xerrors = 5)
114+
@Test def neg_functionArity() = compileFile(negDir, "function-arity", xerrors = 7)
115115
@Test def neg_typedapply() = compileFile(negDir, "typedapply", xerrors = 3)
116116
@Test def neg_typedIdents() = compileDir(negDir, "typedIdents", xerrors = 2)
117117
@Test def neg_assignments() = compileFile(negDir, "assignments", xerrors = 3)

tests/neg/function-arity.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ object Test {
2222
def foo(a: Any => String) = ()
2323
foo((a: Int, b: String) => a + b) // error: none of the overloaded alternatives of method foo match arguments (Int, Int)
2424
}
25+
object jasonComment {
26+
implicit def i2s(i: Int): String = i.toString
27+
((x: String, y: String) => 42) : (((Int, Int)) => String) // error
28+
}

0 commit comments

Comments
 (0)