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

annotation in inferred type, spurious type error

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.3
    • Fix Version/s: None
    • Component/s: Type Inference
    • Labels:
      None

      Description

      trait DataSetup {
        type Memory <: AnyRef with Serializable 
        def run(): Memory
      }
      
      object Use {
      
        val dataSetup = new DataSetup {     // <---- error reported here
          case class Mem(ids: List[Int])
          type Memory = Mem
          def run(): Memory = {
            val ids = List(1,2,3)
            Mem(ids)
          }
        }
      
      }
      

      As reported: http://stackoverflow.com/questions/20460274/confusing-scala-type-mismatch-error-with-uncheckedvariance-in-signature/20460991

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          Cut down:

          class ann extends annotation.StaticAnnotation
          
          object Use { 
            val dataSetup = new AnyRef {     // <---- error reported here
              class Mem { def x: (Int @ann) = 0 }
              type Memory = Mem
            }
          }
          
          /**
          error: type mismatch;
           found   : AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)}
           required: AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int @ann}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)}
           */
          
          Show
          Jason Zaugg added a comment - Cut down: class ann extends annotation.StaticAnnotation object Use { val dataSetup = new AnyRef { // <---- error reported here class Mem { def x: (Int @ann) = 0 } type Memory = Mem } } /** error: type mismatch; found : AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)} required: AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int @ann}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)} */
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/3267
          Show
          Jason Zaugg added a comment - Related: SI-1939 https://github.com/scala/scala/commit/321338da04a6ca9bcc9b77ae663ed27f26a67d85
          Hide
          Paul Phillips added a comment -

          " required: AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)"

          I lost count at some point but I didn't notice that many refinements of AnyRef. Might be time to do something about this type printing pathology.

          Show
          Paul Phillips added a comment - " required: AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)" I lost count at some point but I didn't notice that many refinements of AnyRef. Might be time to do something about this type printing pathology.

            People

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

              Dates

              • Created:
                Updated:

                Development