-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix synthetic type bounds in Tasty reflect #4601
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 |
---|---|---|
|
@@ -112,6 +112,8 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty | |
this += "TypeTree.Annotated(" += arg += ", " += annot += ")" | ||
case TypeBoundsTree(lo, hi) => | ||
this += "TypeBoundsTree(" += lo += ", " += hi += ")" | ||
case SyntheticBounds() => | ||
this += s"SyntheticBounds()" | ||
} | ||
|
||
def visitCaseDef(x: CaseDef): Buffer = { | ||
|
@@ -188,7 +190,8 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty | |
case Type.PolyType(argNames, argBounds, resType) => | ||
this += "Type.PolyType(" ++= argNames += ", " ++= argBounds += ", " += resType += ")" | ||
case Type.TypeLambda(argNames, argBounds, resType) => | ||
this += "Type.TypeLambda(" ++= argNames += ", " ++= argBounds += ", " += resType += ")" | ||
// resType is not printed to avoid cycles | ||
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. I'm curious what kind of cycles can happen here? 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. For definitions, we use the tree of the definition. Somewhere in the body of the type lambda there was a reference to itself and then tried to reprint itself in a loop. |
||
this += "Type.TypeLambda(" ++= argNames += ", " ++= argBounds += ", _)" | ||
case TypeBounds(lo, hi) => | ||
this += "TypeBounds(" += lo += ", " += hi += ")" | ||
case NoPrefix() => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/i2104b/Cons.class */ | ||
class Cons[H, T]() extends java.lang.Object | ||
object Cons { | ||
def apply[H, T](h: H, t: T): Cons[H, T] = scala.Predef.??? | ||
def unapply[H, T](t: Cons[H, T]): scala.Option[Pair[H, T]] = scala.Predef.??? | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/i2104b/Pair.class */ | ||
case class Pair[A, B](_1: A, _2: B) { | ||
override def hashCode(): scala.Int = { | ||
var acc: scala.Int = 2479866 | ||
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair.this._1)) | ||
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair.this._2)) | ||
scala.runtime.Statics.finalizeHash(acc, 2) | ||
} | ||
override def equals(x$0: scala.Any): scala.Boolean = this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match { | ||
case x$0: Pair[Pair.this.A, Pair.this.B] => | ||
this._1.==(x$0._1).&&(this._2.==(x$0._2)) | ||
case _ => | ||
false | ||
}) | ||
override def toString(): java.lang.String = scala.runtime.ScalaRunTime._toString(this) | ||
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[Pair[Pair.this.A, Pair.this.B]] | ||
override def productArity: scala.Int = 2 | ||
override def productPrefix: java.lang.String = "Pair" | ||
override def productElement(n: scala.Int): scala.Any = n match { | ||
case 0 => | ||
this._1 | ||
case 1 => | ||
this._2 | ||
case _ => | ||
throw new java.lang.IndexOutOfBoundsException(n.toString()) | ||
} | ||
} | ||
object Pair extends scala.AnyRef | ||
/** Decompiled from out/posTestFromTasty/pos/i2104b/Test.class */ | ||
object Test { | ||
def main(args: scala.Array[scala.Predef.String]): scala.Unit = { | ||
Cons.apply[scala.Option[scala.Int], scala.None.type](scala.Option.apply[scala.Int](1), scala.None) match { | ||
case Cons(scala.Some(i), scala.None) => | ||
() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
case class Pair[A, B](_1: A, _2: B) | ||
|
||
trait Cons[+H, +T] | ||
|
||
object Cons { | ||
def apply[H, T](h: H, t: T): Cons[H, T] = ??? | ||
def unapply[H, T](t: Cons[H, T]): Option[Pair[H, T]] = ??? | ||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
Cons(Option(1), None) match { | ||
case Cons(Some(i), None) => | ||
} | ||
} | ||
} |
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.
Given the name
synthetic
, I cannot justify the change. Maybe a doc forSynthetic
, I naively assume synthetic bounds are also synthetic.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.
I will add some documentation.
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.
Added