summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-04 00:14:13 -0700
committerJason Zaugg <jzaugg@gmail.com>2013-09-04 00:14:13 -0700
commit0195d7e7cd1f0200915a2a1741f5bd5e5c27def6 (patch)
treeb6cb43f8fd88b39d9b5084d07f136d371a921fc5
parent350ec9547908f0692431370cb1510dcb769576ff (diff)
parentbce786f070afe383d203c4d809ef69803330b340 (diff)
downloadscala-0195d7e7cd1f0200915a2a1741f5bd5e5c27def6.tar.gz
scala-0195d7e7cd1f0200915a2a1741f5bd5e5c27def6.tar.bz2
scala-0195d7e7cd1f0200915a2a1741f5bd5e5c27def6.zip
Merge pull request #2876 from retronym/ticket/7782
SI-7782 Derive type skolems at the ground level
-rw-r--r--src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala9
-rw-r--r--test/files/pos/t7782.scala25
-rw-r--r--test/files/pos/t7782b.scala25
3 files changed, 58 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala
index 3bcb793926..2c2ed351c9 100644
--- a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala
+++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala
@@ -19,6 +19,9 @@ trait ExistentialsAndSkolems {
* can be deskolemized to the original type parameter. (A skolem is a
* representation of a bound variable when viewed inside its scope.)
* !!!Adriaan: this does not work for hk types.
+ *
+ * Skolems will be created at level 0, rather than the current value
+ * of `skolemizationLevel`. (See SI-7782)
*/
def deriveFreshSkolems(tparams: List[Symbol]): List[Symbol] = {
class Deskolemizer extends LazyType {
@@ -30,7 +33,11 @@ trait ExistentialsAndSkolems {
sym setInfo sym.deSkolemize.info.substSym(typeParams, typeSkolems)
}
}
- (new Deskolemizer).typeSkolems
+
+ val saved = skolemizationLevel
+ skolemizationLevel = 0
+ try new Deskolemizer().typeSkolems
+ finally skolemizationLevel = saved
}
def isRawParameter(sym: Symbol) = // is it a type parameter leaked by a raw type?
diff --git a/test/files/pos/t7782.scala b/test/files/pos/t7782.scala
new file mode 100644
index 0000000000..037bdad673
--- /dev/null
+++ b/test/files/pos/t7782.scala
@@ -0,0 +1,25 @@
+package pack
+
+object Test {
+ import O.empty
+ empty // this will trigger completion of `test`
+ // with skolemizationLevel = 1
+}
+
+object O {
+ // order matters (!!!)
+
+ // this order breaks under 2.10.x
+ def empty[E]: C[E] = ???
+ def empty(implicit a: Any): Any = ???
+}
+
+abstract class C[E] {
+ def foo[BB](f: BB)
+ def test[B](f: B): Any = foo(f)
+ // error: no type parameters for method foo: (<param> f: BB)scala.this.Unit exist so that it can be applied to arguments (B&1)
+ // --- because ---
+ // argument expression's type is not compatible with formal parameter type;
+ // found : B&1
+ // required: ?BB
+}
diff --git a/test/files/pos/t7782b.scala b/test/files/pos/t7782b.scala
new file mode 100644
index 0000000000..09da4a5c5b
--- /dev/null
+++ b/test/files/pos/t7782b.scala
@@ -0,0 +1,25 @@
+package pack
+
+object Test {
+ import O.empty
+ empty // this will trigger completion of `test`
+ // with skolemizationLevel = 1
+}
+
+object O {
+ // order matters (!!!)
+
+ // this order breaks under 2.11.x
+ def empty(implicit a: Any): Any = ???
+ def empty[E]: C[E] = ???
+}
+
+abstract class C[E] {
+ def foo[BB](f: BB)
+ def test[B](f: B): Any = foo(f)
+ // error: no type parameters for method foo: (<param> f: BB)scala.this.Unit exist so that it can be applied to arguments (B&1)
+ // --- because ---
+ // argument expression's type is not compatible with formal parameter type;
+ // found : B&1
+ // required: ?BB
+}