summaryrefslogtreecommitdiff
path: root/test/files/pos/t5330.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-20 21:46:23 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-11-14 10:50:04 -0800
commit085b6a5bbed3839238c5cc0434281cf8e4c1ad19 (patch)
treed86b3ffa4e2045634de6728181dc868a46f0129e /test/files/pos/t5330.scala
parented6520b4fa002ea143cead5eb3633839d500e08d (diff)
downloadscala-085b6a5bbed3839238c5cc0434281cf8e4c1ad19.tar.gz
scala-085b6a5bbed3839238c5cc0434281cf8e4c1ad19.tar.bz2
scala-085b6a5bbed3839238c5cc0434281cf8e4c1ad19.zip
SI-5330, SI-6014 deal with existential self-type
This has been broken since https://github.com/scala/scala/commit/b7b81ca2#L0L567. The existential rash is treated in a similar manner as in fc24db4c. Conceptually, the fix would be `def selfTypeSkolemized = widen.skolemizeExistential.narrow`, but simply widening before narrowing achieves the same thing. Since we're in existential voodoo territory, let's go for the minimal fix: replacing `this.narrow` by `widen.narrow`. -- Original patch by @retronym in #1074, refined by @paulp to only perform widen.narrow incantation if there are existentials present in the widened type, as narrowing is expensive when the type is not a singleton. The result is that compiling the entirety of quick, that code path is hit only 143 times. All the other calls hit .narrow directly as before. It looks like the definition of negligible in the diff of -Ystatistics when compiling src/library/scala/collection: < #symbols : 306315 --- > #symbols : 306320 12c13 < #unique types : 293859 --- > #unique types : 293865 I'm assuming based on the 2/1000ths of a percent increase in symbol and type creation that wall clock is manageable, but I didn't measure it.
Diffstat (limited to 'test/files/pos/t5330.scala')
-rw-r--r--test/files/pos/t5330.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/files/pos/t5330.scala b/test/files/pos/t5330.scala
new file mode 100644
index 0000000000..813acd4b83
--- /dev/null
+++ b/test/files/pos/t5330.scala
@@ -0,0 +1,22 @@
+trait FM[A] {
+ def map(f: A => Any)
+}
+
+trait M[A] extends FM[A] {
+ def map(f: A => Any)
+}
+
+trait N[A] extends FM[A]
+
+object test {
+ def kaboom(xs: M[_]) = xs map (x => ()) // missing parameter type.
+
+ def okay1[A](xs: M[A]) = xs map (x => ())
+ def okay2(xs: FM[_]) = xs map (x => ())
+ def okay3(xs: N[_]) = xs map (x => ())
+}
+
+class CC2(xs: List[_]) {
+ def f(x1: Any, x2: Any) = null
+ def g = xs map (x => f(x, x))
+}