diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-11-06 15:21:19 +0100 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-11-07 12:00:48 +0100 |
commit | a34be74e8f2630f1862a34e538cbe1162d279e5e (patch) | |
tree | a404c5fb955bf1fd1f192895cee32adb805544df /test/files/pos/sammy_exist.scala | |
parent | 9c36a76171d497fe277030d2f682f927ae2657f4 (diff) | |
download | scala-a34be74e8f2630f1862a34e538cbe1162d279e5e.tar.gz scala-a34be74e8f2630f1862a34e538cbe1162d279e5e.tar.bz2 scala-a34be74e8f2630f1862a34e538cbe1162d279e5e.zip |
[sammy] use correct type for method to override
Don't naively derive types for the single method's signature
from the provided function's type, as it may be a subtype
of the method's MethodType.
Instead, once the sam class type is fully defined, determine
the sam's info as seen from the class's type, and use those
to generate the correct override.
```
scala> Arrays.stream(Array(1, 2, 3)).map(n => 2 * n + 1).average.ifPresent(println)
5.0
scala> IntStream.range(1, 4).forEach(println)
1
2
3
```
Also, minimal error reporting
Can't figure out how to do it properly, but some reporting
is better than crashing. Right? Test case that illustrates
necessity of the clumsy stop gap `if (block exists (_.isErroneous))`
enclosed as `sammy_error_exist_no_crash`
added TODO for repeated and by-name params
Diffstat (limited to 'test/files/pos/sammy_exist.scala')
-rw-r--r-- | test/files/pos/sammy_exist.scala | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/test/files/pos/sammy_exist.scala b/test/files/pos/sammy_exist.scala index 95c7c7b68e..f05ae20463 100644 --- a/test/files/pos/sammy_exist.scala +++ b/test/files/pos/sammy_exist.scala @@ -9,16 +9,9 @@ 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) // : Bla should be inferred, when running under -Xexperimental [TODO] + val aBlaSAM = (new S(new Bla)).map(_.foo) val fun: Fun[Bla, Bla] = (x: Bla) => x - val aBlaSAMX = (new S(new Bla)).map(fun) // : Bla should be inferred, when running under -Xexperimental [TODO] + val aBlaSAMX = (new S(new Bla)).map(fun) } -// -// // or, maybe by variance-cast? -// import annotation.unchecked.{uncheckedVariance => uv} -// type SFun[-A, +B] = Fun[_ >: A, _ <: B @uv] -// -// def jf[T, R](f: T => R): SFun[T, R] = (x: T) => f(x): R -// -// val aBlaSAM = (new S(new Bla)).map(jf(_.foo)) // : Bla should be inferred [type checks, but existential inferred]
\ No newline at end of file |