Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotation in inferred type, spurious type error #8071

Open
scabug opened this issue Dec 11, 2013 · 7 comments
Open

annotation in inferred type, spurious type error #8071

scabug opened this issue Dec 11, 2013 · 7 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Dec 11, 2013

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

@scabug
Copy link
Author

scabug commented Dec 11, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8071?orig=1
Reporter: @retronym
Affected Versions: 2.10.3
See #1939

@scabug
Copy link
Author

scabug commented Dec 11, 2013

@retronym said:
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>)}
 */

@scabug
Copy link
Author

scabug commented Dec 11, 2013

@retronym said:
scala/scala#3267

@scabug
Copy link
Author

scabug commented Dec 12, 2013

@retronym said:
Related: #1939

scala/scala@321338d

@scabug
Copy link
Author

scabug commented Dec 14, 2013

@paulp said:
" required: AnyRef{type Mem(in )(in )(in )(in )"

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.

@scabug
Copy link
Author

scabug commented Apr 19, 2014

@paulp said:
This compiles with 2.11.0-RC4.

@scabug
Copy link
Author

scabug commented Apr 19, 2014

@paulp said:
But #8079 doesn't. Just a reminder that it is easy to fix. Java 8 is out and has a lot going for it. One thing scala can do to assist in its survival is offer nicer wrappers around java 8. It has to be possible to write them though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants