We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given:
trait A { type B }
I don't see why this shouldn't compile:
case class DoesntWork(a: A)(b: a.type#B)
Instead I have to do the same thing manually a la:
class Blah(val a: A, rawb: Any) { def b = rawb.asInstanceOf[a.type#B] } object Blah { def apply(a: A)(b: a.type#B) = new Blah(a, b) } // Give it a try val x = new A { type B=Int } Blah(x)(123) // should work Blah(x)("should fail")
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-7930?orig=1 Reporter: David Barri (japgolly) Affected Versions: 2.10.3 Duplicates #5712
Sorry, something went wrong.
@retronym said: Duplicate of #5712.
So far we only have dependent method types; constructors are not supported. It's surprisingly tricky to implement this unfortunately.
Here's a pattern to workaround:
scala> class A { class B } defined class A scala> object O1 extends A; object O2 extends A defined module O1 defined module O2 scala> object Test { class Blah[AA <: A](val a: AA, b: AA#B); object Blah { def apply(a: A)(b: a.B) = new Blah[a.type](a, b) } } defined module Test scala> Test.Blah(O1)(new O1.B) res2: Test.Blah[O1.type] = Test$Blah@54becf73 scala> Test.Blah(O1)(new O2.B) <console>:15: error: type mismatch; found : O2.B required: O1.B Test.Blah(O1)(new O2.B) ^
Could I ask that you please check for duplicate tickets, either by searching JIRA or asking on the mailing list, before lodging new ones? Thanks.
retronym
No branches or pull requests
Given:
I don't see why this shouldn't compile:
Instead I have to do the same thing manually a la:
The text was updated successfully, but these errors were encountered: