Scala Programming Language
  1. Scala Programming Language
  2. SI-8023

spurious kind errors with higher kinded pattern type variables when type constructor isn't complete

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: None
    • Labels:

      Description

      import language._
      
      object Test {
        (null: Any) match {
          case a: A[k] => new B[k]()
        }
      }
      
      class A[K[L[_]]]
      class B[K[L[_]]]
      

      This used to work in 2.10.x by virtue of a bug in refchecks (SI-7756)

      Test case minimized from sbt, in util/collection/src/main/scala/sbt/INode.scala

      Type variables already pick up the bounds:

      import language._
      
      object Test {
        (null: Any) match {
          case a: A[k] => new B[k]()
        }
      }
      
      class A[K <: String]
      class B[K <: String]
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          Oh man, this one depends on compilation order: this works:

          class A[K[L[_]]]
          class B[K[L[_]]]
          
          object Test {
            (null: Any) match {
              case a: A[k] => new B[k]()
            }
          }
          

          The condition in question:

          if (!isComplete)
          	args mapConserve (typedHigherKindedType(_, mode))
          	// if symbol hasn't been fully loaded, can't check kind-arity
          else map2Conserve(args, tparams) { (arg, tparam) =>
          	//@M! the polytype denotes the expected kind
          	typedHigherKindedType(arg, mode, GenPolyType(tparam.typeParams, AnyTpe))
          }
          
          Show
          Jason Zaugg added a comment - Oh man, this one depends on compilation order: this works: class A[K[L[_]]] class B[K[L[_]]] object Test { (null: Any) match { case a: A[k] => new B[k]() } } The condition in question: if (!isComplete) args mapConserve (typedHigherKindedType(_, mode)) // if symbol hasn't been fully loaded, can't check kind-arity else map2Conserve(args, tparams) { (arg, tparam) => //@M! the polytype denotes the expected kind typedHigherKindedType(arg, mode, GenPolyType(tparam.typeParams, AnyTpe)) }
          Hide
          Jason Zaugg added a comment -

          We might be able to make this work in the same place that we `enhanceBounds`.

          Show
          Jason Zaugg added a comment - We might be able to make this work in the same place that we `enhanceBounds`.
          Hide
          Jason Zaugg added a comment -

          Here's what's required to make this work in `typedBind` (the "bull in the china store" approach of not trying to avoid cycles)

          https://github.com/retronym/scala/compare/ticket;8023?expand=1

          Show
          Jason Zaugg added a comment - Here's what's required to make this work in `typedBind` (the "bull in the china store" approach of not trying to avoid cycles) https://github.com/retronym/scala/compare/ticket;8023?expand=1
          Hide
          Jason Zaugg added a comment -

          See: https://github.com/scala/scala/commit/218c5a8223 "previous change caused cyclic references.."

          Show
          Jason Zaugg added a comment - See: https://github.com/scala/scala/commit/218c5a8223 "previous change caused cyclic references.."
          Hide
          Adriaan Moors added a comment -

          Always scary to see that "authored 7 years ago", especially when prefixed with your own name.

          Show
          Adriaan Moors added a comment - Always scary to see that "authored 7 years ago", especially when prefixed with your own name.
          Hide
          Jason Zaugg added a comment -

          It might be best to change ones name by deed poll after a decent stretch of time in one codebase.

          PR: https://github.com/scala/scala/pull/3212

          Show
          Jason Zaugg added a comment - It might be best to change ones name by deed poll after a decent stretch of time in one codebase. PR: https://github.com/scala/scala/pull/3212

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development