Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5845

unresolved type constructor during implicit resolution: crash

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M3, Scala 2.10.0
    • Component/s: None
    • Labels:
      None

      Description

      The error message is similar to SI-4365, but this is not code or file order dependent that I have determined.

      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)
      }
      

      T in class Num cannot be instantiated from ?CC
      	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:43)
      	at scala.tools.nsc.Global.abort(Global.scala:225)
      	at scala.reflect.internal.Types$AsSeenFromMap.throwError$1(Types.scala:4318)
      	at scala.reflect.internal.Types$AsSeenFromMap.toInstance$1(Types.scala:4372)
      	at scala.reflect.internal.Types$AsSeenFromMap.apply(Types.scala:4376)
      	at scala.reflect.internal.Types$TypeMap$$anonfun$noChangeToSymbols$2.apply(Types.scala:4011)
      	at scala.reflect.internal.Types$TypeMap$$anonfun$noChangeToSymbols$2.apply(Types.scala:4011)
      	at scala.collection.LinearSeqOptimized$class.forall(LinearSeqOptimized.scala:69)
      

        Attachments

          Activity

          Hide
          retronym Jason Zaugg added a comment -

          Fixing the crash is easy enough; getting the inference to work for a view is harder:

          https://github.com/retronym/scala/commit/82fb9a74263d1de17874350b2f002f3cf141f2f4

          Show
          retronym Jason Zaugg added a comment - Fixing the crash is easy enough; getting the inference to work for a view is harder: https://github.com/retronym/scala/commit/82fb9a74263d1de17874350b2f002f3cf141f2f4
          Hide
          retronym Jason Zaugg added a comment -

          This version works well (even in 2.9.x with -Ydependent-method-types).

          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
          }
          

          Show
          retronym Jason Zaugg added a comment - This version works well (even in 2.9.x with -Ydependent-method-types). 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 }
          Show
          retronym Jason Zaugg added a comment - https://github.com/scala/scala/pull/636
          Hide
          odersky Martin Odersky added a comment -

          The fix for SI-4881 fixes the inference for this one also.

          Show
          odersky Martin Odersky added a comment - The fix for SI-4881 fixes the inference for this one also.
          Hide
          odersky Martin Odersky added a comment -

          Correction: It fixes it in one of the two failing cases.

          Show
          odersky Martin Odersky added a comment - Correction: It fixes it in one of the two failing cases.

            People

            • Assignee:
              retronym Jason Zaugg
              Reporter:
              extempore Paul Phillips
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: