Permalink
Browse files

SI-5845 Advances the example from a crasher to an inference failure.

The inference failure itself seems like an instance of of SI-3346.

But dependent method types (which triggered the crash), can be employed
to avoid inferring the type constructor CC.

class Num[T] {
  def mkOps = new Ops
  class Ops { def +++(rhs: T) = () }
}

class A {
  implicit def infixOps[T](lhs: T)(implicit num: Num[T]): num.Ops = num.mkOps
  implicit val n1: Num[Int] = new Num[Int] { }
  5 +++ 5
}
  • Loading branch information...
retronym committed May 28, 2012
1 parent bcc8280 commit 8d4ce1da77bd6bf4a2311c9e30bd815a9aedae1b
Showing with 24 additions and 1 deletion.
  1. +1 −1 src/compiler/scala/reflect/internal/Types.scala
  2. +7 −0 test/files/neg/t5845.check
  3. +16 −0 test/files/neg/t5845.scala
@@ -4318,7 +4318,7 @@ trait Types extends api.Types { self: SymbolTable =>
def throwError = abort("" + tp + sym.locationString + " cannot be instantiated from " + pre.widen)
val symclazz = sym.owner
if (symclazz == clazz && !pre.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) {
if (symclazz == clazz && !pre.widen.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) {
// have to deconst because it may be a Class[T].
pre.baseType(symclazz).deconst match {
case TypeRef(_, basesym, baseargs) =>
@@ -0,0 +1,7 @@
t5845.scala:9: error: value +++ is not a member of Int
println(5 +++ 5)
^
t5845.scala:15: error: value +++ is not a member of Int
println(5 +++ 5)
^
two errors found
View
@@ -0,0 +1,16 @@
class Num[T] {
def mkOps = new Ops
class Ops { def +++(rhs: T) = () }
}
class A {
implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps
implicit val n1 = new Num[Int] { }
println(5 +++ 5)
}
class B {
implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps
implicit val n1 = new Num[Int] {}
println(5 +++ 5)
}

0 comments on commit 8d4ce1d

Please sign in to comment.