-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2072: erasure and refchecks #2085
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
9892820
e843cc8
8144441
1802fa3
76f1844
535e100
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 |
---|---|---|
|
@@ -96,23 +96,30 @@ trait TypeTestsCasts { | |
/** Transform isInstanceOf OrType | ||
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. Not specific to OrType anymore |
||
* | ||
* expr.isInstanceOf[A | B] ~~> expr.isInstanceOf[A] | expr.isInstanceOf[B] | ||
* expr.isInstanceOf[A & B] ~~> expr.isInstanceOf[A] & expr.isInstanceOf[B] | ||
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. 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. An identical commit has now been merged as part of #2082 |
||
* | ||
* The transform happens before erasure of `argType`, thus cannot be merged | ||
* with `transformIsInstanceOf`, which depends on erased type of `argType`. | ||
*/ | ||
def transformOrTypeTest(qual: Tree, argType: Type): Tree = argType.dealias match { | ||
def transformTypeTest(qual: Tree, argType: Type): Tree = argType.dealias match { | ||
case OrType(tp1, tp2) => | ||
evalOnce(qual) { fun => | ||
transformOrTypeTest(fun, tp1) | ||
.select(nme.OR) | ||
.appliedTo(transformOrTypeTest(fun, tp2)) | ||
transformTypeTest(fun, tp1) | ||
.select(defn.Boolean_||) | ||
.appliedTo(transformTypeTest(fun, tp2)) | ||
} | ||
case AndType(tp1, tp2) => | ||
evalOnce(qual) { fun => | ||
transformTypeTest(fun, tp1) | ||
.select(defn.Boolean_&&) | ||
.appliedTo(transformTypeTest(fun, tp2)) | ||
} | ||
case _ => | ||
transformIsInstanceOf(qual, erasure(argType)) | ||
} | ||
|
||
if (sym eq defn.Any_isInstanceOf) | ||
transformOrTypeTest(qual, tree.args.head.tpe) | ||
transformTypeTest(qual, tree.args.head.tpe) | ||
else if (sym eq defn.Any_asInstanceOf) | ||
transformAsInstanceOf(erasure(tree.args.head.tpe)) | ||
else tree | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
final case class Fix[F[_]](unfix: F[Fix[F]]) extends AnyVal | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
trait T { | ||
def m = "" ; | ||
val v = "" ; | ||
lazy val lv = ""; | ||
object o | ||
} | ||
|
||
// deferred methods always lose against concrete ones, so none of these declarations actually survive in bytecode | ||
// the mixed in members from T take precedence in the linearisation order | ||
abstract class AC extends T { | ||
def m: Any | ||
def v: Any | ||
def lv: Any | ||
def o: Any | ||
} | ||
|
||
class C extends AC{} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val c = new C | ||
c.m | ||
c.v | ||
c.lv | ||
c.o | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
trait T { | ||
def m = "" ; | ||
val v = "" ; | ||
lazy val lv = ""; | ||
object o; | ||
} | ||
|
||
// deferred methods always lose against concrete ones, so none of these declarations actually survive in bytecode | ||
// the mixed in members from T take precedence in the linearisation order | ||
abstract class AC{ | ||
def m: Any | ||
def v: Any | ||
def lv: Any | ||
def o: Any | ||
} | ||
|
||
class C extends AC with T{} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val c = new C | ||
c.m | ||
c.v | ||
c.lv | ||
c.o | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
trait T { lazy val x: String = "foo" } | ||
trait U { def x: Any } | ||
class AC extends T with U // { def x: Any } | ||
|
||
abstract class B { def x: Any } | ||
class C extends B { def x: String = "abc" } | ||
|
||
package p2 { | ||
trait T1 { def f: Any } | ||
trait T2 extends T1 { def f: Number = ??? } | ||
trait T3 extends T1 { override def f: Integer = ??? } | ||
class C extends T2 with T3 | ||
} | ||
|
||
package p3 { | ||
|
||
trait A { def f: Any } | ||
trait B extends A { def f: String } | ||
class C extends B { def f = "abc" } | ||
|
||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val ac = new AC | ||
ac.x | ||
(ac: T).x | ||
(ac: U).x | ||
(new C).x | ||
((new C): B).x | ||
val p2c = new p2.C | ||
p2c.f | ||
(p2c: p2.T1).f | ||
(p2c: p2.T2).f | ||
(p2c: p2.T3).f | ||
val p3c = new p3.C | ||
p3c.f | ||
(p3c: p3.A).f | ||
(p3c: p3.B).f | ||
} | ||
} |
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.
This is not a helpful comment. Someone might need to look at this eventually and will be very confused. Also do you need both
installAfter
andtransformAfter
?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.
Yes. The comment here would entirely repeat all the history of transformAfter. I don't think it's worth simplifying it here. To understand why it's needed here one need to read the entire description of 979ee0f which introduces transformAfter
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.
Then the comment can say "See the commit message of 979ee0f for more information."