Closed scabug closed 10 years ago
Imported From: https://issues.scala-lang.org/browse/SI-7782?orig=1 Reporter: @retronym Affected Versions: 2.10.1, 2.11.0-M3 Other Milestones: 2.11.0-M6
@retronym said: Further reduced:
package pack
object Named {
import O.empty
def foo(empty: Any): Any = ???
// is `empty` a named arg or an assignment? Checking for that has nasty side effects!
foo(empty = ???)
}
object O {
// order matters (!!!)
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)
}
@retronym said (edited on Aug 26, 2013 9:58:29 AM UTC): Okay, this is skolem related.
package pack
object Test {
import O.empty
empty // this will trigger PolyTypeCompleter of `test`
// which picks up `skolemizationLevel = 1` from the in-flight `isAsSpecific` check
// that happens to be computing `Any <:< pack.this.C[E] forSome { E }`
}
object O {
// order matters (!!!)
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
}
@retronym said: 2.10.2 is also susceptible to the problem:
package pack
object Test {
import O.empty
empty // this will trigger completion of `test`
// with skolemizationLevel = 1
}
object O {
// order matters (!!!)
// def empty(implicit a: Any): Any = ???
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
}
I had to switch the order of the empty
methods around as a inferExprAlternative
seems to try these in a a different order in master, and if the completers trigger earlier outside of:
case ExistentialType(_, _) =>
try {
skolemizationLevel += 1
isSubType(tp1.skolemizeExistential, tp2, depth)
} finally {
skolemizationLevel -= 1
}
This test case regresses at: b74c33eb860622e363 "SI-1803, plus documentation and cleanups in Namers, mainly in typeSig".
I think the fix is to force the level of skolems derived in PolyTypeCompleter
to 0.
@retronym said: PR: https://github.com/scala/scala/pull/2876