Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4101 from adriaanm/sam-ex
[sammy] eta-expansion, overloading, existentials
- Loading branch information
Showing
20 changed files
with
183 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sammy_error_exist_no_crash.scala:5: error: Could not derive subclass of F[? >: String] | ||
(with SAM `def method apply(s: String)Int`) | ||
based on: ((x$1: String) => x$1.<parseInt: error>). | ||
bar(_.parseInt) | ||
^ | ||
one error found |
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 @@ | ||
-Xexperimental |
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,6 @@ | ||
abstract class F[T] { def apply(s: T): Int } | ||
|
||
object NeedsNiceError { | ||
def bar(x: F[_ >: String]) = ??? | ||
bar(_.parseInt) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-Xexperimental |
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> typeOf[java.util.stream.Stream[_]].nonPrivateMember(TermName("map")).info | ||
// [R](x$1: java.util.function.Function[_ >: T, _ <: R])java.util.stream.Stream[R] | ||
|
||
// java.util.function.Function | ||
trait Fun[A, B] { def apply(x: A): B } | ||
|
||
// java.util.stream.Stream | ||
class S[T](x: T) { def map[R](f: Fun[_ >: T, _ <: R]): R = f(x) } | ||
|
||
class Bla { def foo: Bla = this } | ||
|
||
// NOTE: inferred types show unmoored skolems, should pack them to display properly as bounded wildcards | ||
object T { | ||
val aBlaSAM = (new S(new Bla)).map(_.foo) | ||
val fun: Fun[Bla, Bla] = (x: Bla) => x | ||
val aBlaSAMX = (new S(new Bla)).map(fun) | ||
} |
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 @@ | ||
-Xexperimental |
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,9 @@ | ||
trait Consumer[T] { | ||
def consume(x: T): Unit | ||
} | ||
|
||
object Test { | ||
def foo(x: String): Unit = ??? | ||
def foo(): Unit = ??? | ||
val f: Consumer[_ >: String] = foo | ||
} |
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 @@ | ||
-Xexperimental |
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,8 @@ | ||
trait IntConsumer { | ||
def consume(x: Int): Unit | ||
} | ||
|
||
object Test { | ||
def anyConsumer(x: Any): Unit = ??? | ||
val f: IntConsumer = anyConsumer | ||
} |
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 @@ | ||
-Xexperimental |
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,22 @@ | ||
trait Comparinator[T] { def compare(a: T, b: T): Int } | ||
|
||
object TestOkay { | ||
def sort(x: Comparinator[_ >: String]) = () | ||
sort((a: String, b: String) => a.compareToIgnoreCase(b)) | ||
} | ||
|
||
object TestOkay2 { | ||
def sort[T](x: Comparinator[_ >: T]) = () | ||
sort((a: String, b: String) => a.compareToIgnoreCase(b)) | ||
} | ||
|
||
object TestOkay3 { | ||
def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = () | ||
sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b)) | ||
} | ||
|
||
object TestKoOverloaded { | ||
def sort[T](xs: Option[T]) = () | ||
def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = () | ||
sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b)) | ||
} |
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 @@ | ||
WrappedArray(1) |
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 @@ | ||
-Xexperimental |
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,8 @@ | ||
trait RepeatedSink { def accept(a: Any*): Unit } | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val f: RepeatedSink = (a) => println(a) | ||
f.accept(1) | ||
} | ||
} |