-
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9892820
Fix #2072: Rechecks should allow parents to implement abstract members
DarkDimius e843cc8
Fix #2072: Erasure should allow generating forwarders up the hierarchy.
DarkDimius 8144441
Add tests for #2072
DarkDimius 1802fa3
Fix #2084.
DarkDimius 76f1844
track that we we can compile recursive value classes #2073.
DarkDimius 535e100
Fix #2072: use dark magic in proper way.
DarkDimius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,23 +96,30 @@ trait TypeTestsCasts { | |
/** Transform isInstanceOf OrType | ||
* | ||
* 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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Not specific to OrType anymore