-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #7044: Approximate GADT bounds to avoid explicit type ascriptions #8728
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,19 +25,6 @@ object test3 { | |
} | ||
} | ||
|
||
// Example contributed by Jason. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test has been removed as we discussed with @AleksanderBG and we think it is correct for it to actually compile. My reasoning is following:
we want y to conform to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be re added as a pos test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, I have added it. |
||
object test4 { | ||
class Base { | ||
type N | ||
|
||
class Tree[-S, -T >: Option[S]] | ||
|
||
def g(x: Any): Tree[_, _ <: Option[N]] = x match { | ||
case y: Tree[_, _] => y // error -- used to work (because of capture conversion?) | ||
} | ||
} | ||
} | ||
|
||
class Test5 { | ||
"": ({ type U = this.type })#U // error | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// test based on an example code by @Blaisorblade | ||
object GadtAscription { | ||
enum Var[G, A] { | ||
case Z[G, A]() extends Var[(A, G), A] | ||
case S[G, A, B](x: Var[G, A]) extends Var[(B, G), A] | ||
} | ||
|
||
import Var._ | ||
def evalVar[G, A](x: Var[G, A])(rho: G): A = x match { | ||
case _: Z[g, a] => | ||
rho(0) | ||
case s: S[g, a, b] => | ||
evalVar(s.x)(rho(1)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
object i7044 { | ||
case class Seg[T](pat:Pat[T], body:T) | ||
|
||
trait Pat[T] | ||
object Pat { | ||
case class Expr() extends Pat[Int] | ||
case class Opt[S](el:Pat[S]) extends Pat[Option[S]] | ||
} | ||
|
||
def test[T](s:Seg[T]):Int = s match { | ||
case Seg(Pat.Expr(),body) => body + 1 | ||
case Seg(Pat.Opt(Pat.Expr()),body) => body.get | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should introduce a proper internal construct for these trees. Maybe have a
scala.internal.bla.dummyTree[T]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the
unapply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can improve on this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolasstucki can you elaborate on what
scala.internal.bla.dummyTree[T]
should be? Some sort of special fictional value? I think creating a specialTree
subclass for this purpose would work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarter it turned out that it was
dummyTreeOfType
that was the source of thenull
we talked about. Could you chime in with an opinion on whether it ever makes sense toadapt
dummy trees created by this function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly no clue, I myself only learned about dummyTreeOfType recently.