Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow eta-expansion of methods with dependent types
- Loading branch information
Showing
7 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
test/files/neg/error_dependentMethodTpeConversionToFunction.check
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
test/files/neg/error_dependentMethodTpeConversionToFunction.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
scala> val a = "obj" | ||
val a: String = obj | ||
|
||
scala> def f(x: Int): a.type = a | ||
def f(x: Int): a.type | ||
|
||
scala> val f1 = f _ | ||
val f1: Int => a.type = $Lambda | ||
|
||
scala> val f2: Int => a.type = f | ||
val f2: Int => a.type = $Lambda | ||
|
||
scala> val f3: Int => Object = f | ||
val f3: Int => Object = $Lambda | ||
|
||
scala> :quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
object NoMoreNeg { | ||
def foo(x: AnyRef): x.type = x | ||
val x: AnyRef => Any = foo | ||
} | ||
|
||
object t12641 { | ||
def f(sb: StringBuilder) = Option("").foreach(sb.append) | ||
} | ||
|
||
object t12641a { | ||
trait A { | ||
def foo(s: String): this.type | ||
def foo(s: Int): this.type | ||
} | ||
trait T { | ||
val a1: A | ||
val o: Option[String] | ||
|
||
def t(a2: A): Unit = { | ||
o.foreach(a1.foo) | ||
o.foreach(a2.foo) | ||
|
||
val f1: String => a2.type = a2.foo _ | ||
val f2: String => A = a2.foo _ | ||
} | ||
} | ||
} | ||
|
||
object t12641b { | ||
trait A { | ||
def foo(s: String): this.type | ||
} | ||
trait T { | ||
val a1: A | ||
val o: Option[String] | ||
|
||
def t(a2: A): Unit = { | ||
o.foreach(a1.foo) | ||
o.foreach(a2.foo) | ||
|
||
val f1: String => a2.type = a2.foo _ | ||
val f2: String => A = a2.foo _ | ||
} | ||
} | ||
} | ||
|
||
import scala.tools.partest.ReplTest | ||
|
||
object Test extends ReplTest { | ||
override protected def normalize(s: String): String = s.replaceAll("(Lambda).*", "$1") | ||
def code = """ | ||
val a = "obj" | ||
def f(x: Int): a.type = a | ||
val f1 = f _ | ||
val f2: Int => a.type = f | ||
val f3: Int => Object = f | ||
""".trim | ||
} |