Skip to content
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

Early Definintion order incorrect if a class extends a trait with Early Definitions #2796

Closed
scabug opened this issue Dec 11, 2009 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Dec 11, 2009

I didn't get an answer on the list, so I'll raise a bug.

trait Base {
  val abstractVal: String
  final val useAbstractVal = abstractVal
}

trait T1 extends {
  val abstractVal = "T1.abstractVal"
} with Base
 
class C3 extends T1
 
assert(new C3().useAbstractVal eq null) // why not == "T1.abstractVal" ?
[[syntax trees at end of icode]]// Scala source: early.scala
package <empty> {
  abstract trait Base extends java.lang.Object with ScalaObject {
    final <accessor> def Base$$_setter_$$useAbstractVal_=(x$$1: java.lang.String): Unit;
    <stable> <accessor> def abstractVal(): java.lang.String;
    final <stable> <accessor> def useAbstractVal(): java.lang.String
  };
  abstract trait T1 extends java.lang.Object with Base with ScalaObject {
    <accessor> def T1$$_setter_$$abstractVal_=(x$$1: java.lang.String): Unit;
    <stable> <accessor> def abstractVal(): java.lang.String
  };
  class C3 extends java.lang.Object with T1 with ScalaObject {
    <stable> <accessor> def abstractVal(): java.lang.String = C3.this.abstractVal;
    private[this] val abstractVal: java.lang.String = _;
    <accessor> def T1$$_setter_$$abstractVal_=(x$$1: java.lang.String): Unit = C3.this.abstractVal = x$$1;
    final <stable> <accessor> def useAbstractVal(): java.lang.String = C3.this.useAbstractVal;
    private[this] val useAbstractVal: java.lang.String = _;
    final <accessor> def Base$$_setter_$$useAbstractVal_=(x$$1: java.lang.String): Unit = C3.this.useAbstractVal = x$$1;
    def this(): C3 = {
      C3.super.this();
      Base$$class./*Base$$class*/$$init$$(C3.this);
      T1$$class./*T1$$class*/$$init$$(C3.this);
      ()
    }
  };
  abstract trait Base$$class extends  {
    def /*Base$$class*/$$init$$($$this: Base): Unit = {
      $$this.Base$$_setter_$$useAbstractVal_=($$this.abstractVal());
      ()
    }
  };
  abstract trait T1$$class extends  {
    def /*T1$$class*/$$init$$($$this: T1): Unit = {
      val abstractVal: java.lang.String = "T1.abstractVal";
      $$this.T1$$_setter_$$abstractVal_=(abstractVal);
      ()
    }
  }
}

http://gist.github.com/253684

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Dec 11, 2009

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Dec 14, 2009

@hubertp said:
Yes, the early definition doesn't work for traits initialization ATM and I guess we should provide it.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 26, 2012

@retronym said:
Until we can fix it, let's issue a warning.

scala/scala#777

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Dec 4, 2012

@retronym said:
Closing; it seems we're more likely to invest in fully blown trait parameters than into expanding early definitions for traits.

@scabug scabug closed this Dec 4, 2012
@scabug scabug added the won't fix label Apr 7, 2017
@scabug scabug added this to the 2.10.0-M4 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.