-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add/trait parameters #639
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
Merged
Merged
Add/trait parameters #639
Conversation
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
trait U(a: Any) extends T {
def d = a // okay
val v = a // okay
a // crash
}
|
I think this is a clearer way to express the test cases: object Trace {
private var results = List[Any]()
def apply[A](a: A) = {results ::= a; a}
def fetchAndClear(): Seq[Any] = try results.reverse finally results = Nil
}
trait T(a: Any) {
val ta = a
Trace(s"T.<init>($ta)")
val t_val = Trace("T.val")
}
trait U(a: Any) extends T {
val ua = a
Trace(s"U.<init>($ua)")
}
object Test {
def check(expected: Any) = {
val actual = Trace.fetchAndClear()
if (actual != expected)
sys.error(s"\n$actual\n$expected")
}
def main(args: Array[String]): Unit = {
new T(Trace("ta")) with U(Trace("ua")) {}
check(List("ta", "T.<init>(ta)", "T.val", "ua", "U.<init>(ua)"))
new U(Trace("ua")) with T(Trace("ta")) {}
check(List("ta", "T.<init>(ta)", "T.val", "ua", "U.<init>(ua)"))
}
}
|
87f0f93
to
9dcb95b
Compare
@retronym Yes, that was the corner case I meant. |
9dcb95b
to
04a5372
Compare
rebased to master |
Need to suppress the flag when copying symbols.
A parent trait may not be parameterized (as in T()) if the calling class does not directly implement that trait.
Add necessary logic to Mixin. Also add tests that all parameterized traits are called with parameters set.
Verify that the initilialization order described in scala#640 is correctly implemented.
(reverted from commit 2c55900) Mixin should drop the ParamAccessor flag anyway in traits, so there is no need to mask it when creating implementations of trait definitions.
Parameter accessors in traits have the ParamAccessor flag removed in the Mixin transformSym method.
Reason: The ParamAccessor flag will be reset later in Mixin. We do not want to rewrite the references to a trait parameter accessor then, so it's better to generate all references with a `this.` prefix from the start.
Lazy Scala2 fields and trait parameters touched the same code in Mixin and the merge dropped essential logic. Also cleaned up some of the code having to do with lazy Scala2 fields.
ee1277a
to
0369f1e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements #640. @retronym do you want to take a look?