-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle outers of trait as concrete semantics
For traits, its outers will be fields of the class that extends the trait. As the prefix is stable and is a valid value before any super class. Therefore, we may think the outers for are immediately set after the class parameters. Also, when trying promotion of warm values, we never try warm values whose fields are not fully filled -- which corresponds to promote ThisRef with empty fields, and errors will be reported when the class is checked separately.
- Loading branch information
1 parent
f052bcb
commit e07bb78
Showing
3 changed files
with
87 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,20 @@ | ||
abstract class A { | ||
bar() | ||
def bar(): Unit | ||
} | ||
|
||
class Outer { | ||
val a: Int = 5 | ||
trait B { | ||
def bar() = assert(a == 5) | ||
} | ||
} | ||
|
||
class M(val o: Outer) extends A with o.B { | ||
val n: Int = 10 | ||
} | ||
|
||
class Dummy { | ||
val m: Int = n + 4 | ||
val n: Int = 10 // error | ||
} |
This file contains 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,25 @@ | ||
abstract class A { | ||
bar(this) | ||
def bar(x: A): Unit | ||
} | ||
|
||
class Outer { | ||
val a: Int = 4 | ||
trait B { | ||
def bar(x: A) = println(a) | ||
} | ||
} | ||
|
||
class M(val o: Outer, c: Container) extends A with o.B | ||
|
||
class Container { | ||
val o = new Outer | ||
val m = new M(o, this) | ||
val s = "hello" | ||
} | ||
|
||
class Dummy { | ||
val m: Int = n + 4 | ||
val n: Int = 10 // error | ||
} | ||
|