-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[REVISIT] Avoid compiler crash when overriding lazy val with abstract def [ci: last-only] #10505
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
Conversation
// if current class is a trait, add an abstract method for accessor `sym` | ||
// ditto for a super accessor (will get an RHS in completeSuperAccessor) | ||
if (clazz.isTrait || sym.isSuperAccessor) addDefDef(sym) | ||
// implement methods mixed in from a supertrait (the symbols were created by mixinTraitMembers) | ||
else if (sym.hasFlag(ACCESSOR) && !sym.hasFlag(DEFERRED)) { | ||
assert(sym hasFlag (PARAMACCESSOR), s"mixed in $sym from $clazz is not param?!?") | ||
else if (sym.hasFlag(ACCESSOR) && sym.hasNoFlags(DEFERRED|LAZY)) { |
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 doesn't skip only the assertion, but also addDedDef
. Not sure if that's correct?
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 ran out of midnight before I learned what is going on. Adriaan left comments about lazy vals from fields work, which are on my reading list. Mixin used to do work for lazy vals before then?
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.
Plenty of time to add tests before 2.13.13.
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.
berühmte letzte Worte.
af73368
to
b844a1a
Compare
b844a1a
to
e1cce93
Compare
@lrytz re-review? |
This is a difficult area; I don't have a good model present about fields and mixin, and didn't dive in their implementaiton. Observationtion from compiling an example with package p
trait T { lazy val x: String = { System.out.println("init"); "hello, world" } }
abstract class A extends T { override def x: Any }
abstract class B extends T
In jshell jshell> var a = new p.A(){}
a ==> $0@20e2cbe0
jshell> a.x()
init
$2 ==> "hello, world"
jshell> a.x()
init
$3 ==> "hello, world" So not a lazy val. |
thanks @lrytz I'll dive back in, as I promised a month ago. 2.13.13 seemed so far away, but Friday 13th is just around the corner. |
Fixes scala/bug#10223