diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-16 17:30:04 +0100 |
---|---|---|
committer | Tobias Schlatter <tobias@meisch.ch> | 2014-03-21 11:24:03 +0100 |
commit | ee1251f37f844bdb4f4ea69177e8183ad74e7b3d (patch) | |
tree | 9540aad09833958cd80de1ddc7cc8087ba943f3e /tests/untried | |
parent | bb90b26fbca27f432ade46ae572b82e1b8027b19 (diff) | |
download | dotty-ee1251f37f844bdb4f4ea69177e8183ad74e7b3d.tar.gz dotty-ee1251f37f844bdb4f4ea69177e8183ad74e7b3d.tar.bz2 dotty-ee1251f37f844bdb4f4ea69177e8183ad74e7b3d.zip |
Fix of t0438 - lambdas and eta expansion
Two fixes were needed
1) When typing a function value (x1: T1, ..., xN: Tn) => e, don't unconditionally issue an error
if the expected function type arity is different from N. Instead, issue an error only
if one of the types T1, ..., Tn is absent. The idea is that only then we need to
consult the expected type for the parameter type. This allows to fix the problem later
by an implicit conversion applied to the function value.
2) When eta-expanding, do not automtically take the arity of the expected function value as the
arity of the generated lambda. Instead, take the method's arity, and copy method parameters
into the lambda in case the arities are different.
Diffstat (limited to 'tests/untried')
-rw-r--r-- | tests/untried/pos/t0301.scala | 12 | ||||
-rw-r--r-- | tests/untried/pos/t0304.scala | 5 | ||||
-rw-r--r-- | tests/untried/pos/t0305.scala | 7 | ||||
-rw-r--r-- | tests/untried/pos/t0438.scala | 12 | ||||
-rw-r--r-- | tests/untried/pos/t0453.scala | 6 |
5 files changed, 0 insertions, 42 deletions
diff --git a/tests/untried/pos/t0301.scala b/tests/untried/pos/t0301.scala deleted file mode 100644 index 24b477601..000000000 --- a/tests/untried/pos/t0301.scala +++ /dev/null @@ -1,12 +0,0 @@ -package fos - -abstract class Expr -case class Var() extends Expr - -object Analyzer { - def substitution(expr: Expr, cls: (Var,Var)): Expr = - expr match { - case cls._2 => cls._1 // source of the error - case _ => expr - } -} diff --git a/tests/untried/pos/t0304.scala b/tests/untried/pos/t0304.scala deleted file mode 100644 index 607a115db..000000000 --- a/tests/untried/pos/t0304.scala +++ /dev/null @@ -1,5 +0,0 @@ -object O { - def f1 = -1; - def f2 = 0-1; - def f3 = f1 + f2; -} diff --git a/tests/untried/pos/t0305.scala b/tests/untried/pos/t0305.scala deleted file mode 100644 index 4838b1fcf..000000000 --- a/tests/untried/pos/t0305.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test extends App { - - def foo(is:Int*) = 1; - def foo(i:Int) = 2; - - assert(foo( List(3):_* ) == 1) -} diff --git a/tests/untried/pos/t0438.scala b/tests/untried/pos/t0438.scala deleted file mode 100644 index dd1e7f9a9..000000000 --- a/tests/untried/pos/t0438.scala +++ /dev/null @@ -1,12 +0,0 @@ -class Foo { - implicit def pair2fun2[A, B, C](f: (A, B) => C): ((A, B)) => C = - {p: (A, B) => f(p._1, p._2) } - - def foo(f: ((Int, Int)) => Int) = f - def bar(x: Int, y: Int) = x + y - - foo({ (x: Int, y: Int) => x + y }) // works - foo(pair2fun2(bar _)) // works - foo(bar _) // error - foo(bar) // same error -} diff --git a/tests/untried/pos/t0453.scala b/tests/untried/pos/t0453.scala deleted file mode 100644 index dfacc5eed..000000000 --- a/tests/untried/pos/t0453.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - val foo = new { - trait Bar - def l () : Bar = { new Bar {} } - } -} |