Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
857cc74
Update tests
EnzeXing Aug 25, 2021
ef43eb5
Add worklist and refactor definition for ThisRef
liufengyun Sep 4, 2021
5d1fe86
Rename Addr to Ref
liufengyun Sep 4, 2021
7279f73
Refactor: make state explicit
liufengyun Sep 5, 2021
20ff7ca
Add constructor to Warm
liufengyun Sep 5, 2021
f5651b5
Revert ThisRef to previous version
liufengyun Sep 5, 2021
6763285
Refactor constructor call
liufengyun Sep 5, 2021
ab09fd2
Make cache part of state
liufengyun Sep 5, 2021
98f9f7e
Handle cache in work list
liufengyun Sep 5, 2021
fb0c347
Don't iterate if errors found
liufengyun Sep 5, 2021
69e314e
Revert heap changes if cache has changed
liufengyun Sep 5, 2021
db11295
Restore cacheResult option for eval
liufengyun Sep 5, 2021
111ac87
Handle callConstructor
liufengyun Sep 6, 2021
29bdb5d
Reset Cache.changed after each iteration
liufengyun Sep 6, 2021
0b1b21f
Tweak log printing of errors
liufengyun Sep 6, 2021
c5daf1d
Fix context for init check
liufengyun Sep 6, 2021
4a71470
Introduce global cache which holds fixed point value
liufengyun Sep 6, 2021
375e0e5
Update tests
liufengyun Sep 7, 2021
6188e8e
Avoid asInstanceOf in logging
liufengyun Sep 7, 2021
5bdd898
Refactor cache
liufengyun Sep 8, 2021
9ea3624
Cache default value in the input cache
liufengyun Sep 8, 2021
d0e71a2
Rename global cache to stable cache
liufengyun Sep 8, 2021
fe3930d
Better encapsulate Cache.assume
liufengyun Sep 8, 2021
5bd83ae
Rename in/out to last/current
liufengyun Sep 8, 2021
2589824
Mark arguments as constructor only
liufengyun Sep 8, 2021
2849052
Add note for tempting but unsound optimization
liufengyun Sep 8, 2021
8a4fe78
Commit cache to stable on error
liufengyun Sep 8, 2021
5b00b1f
Make sure the object of a reference assumption value exists
liufengyun Sep 8, 2021
04aa72b
Add back arguments to ThisRef
liufengyun Sep 8, 2021
ad503fc
Populate parameters of Warm objects by reusing init
liufengyun Sep 8, 2021
fb3b6ca
Make sure the class parameters and outers of warm objects are populated
liufengyun Sep 8, 2021
bc98ce8
Use correct trace
liufengyun Sep 8, 2021
b27d58b
Populate class parameters for warm objects in a heap prepare step
liufengyun Sep 8, 2021
99df102
Try to check warm values immediately
liufengyun Sep 9, 2021
4163fd3
Fix crash: make sure object fresh before calling init
liufengyun Sep 9, 2021
683d537
Be more sensitive for values Warm(outer = ThisRef)
liufengyun Sep 9, 2021
ccbb355
Fix non-determinism in test
liufengyun Sep 9, 2021
fc76549
Make isPopulatingParams a flag in Warm
liufengyun Sep 15, 2021
191877a
Make heap as part of cache
liufengyun Sep 16, 2021
f5540f5
Update test
liufengyun Sep 20, 2021
a15a06c
Add more debugging information
liufengyun Sep 20, 2021
46793f1
Lazily populate warm objects
liufengyun Sep 20, 2021
8bbe384
Add comment
liufengyun Sep 20, 2021
dab8181
Fix non-termination
liufengyun Sep 21, 2021
1ab5316
Fix pickling test
liufengyun Sep 22, 2021
1e802c9
Remove unused parameters of ThisRef
liufengyun Sep 22, 2021
8088217
Fix compilation of scodec
liufengyun Sep 22, 2021
6566756
Apply suggestions from code review
liufengyun Oct 7, 2021
15a51d7
Address review comments
liufengyun Oct 7, 2021
7ee58a3
Address review: Add comment to populateParams
liufengyun Oct 7, 2021
e905cd5
Fix compilation
liufengyun Oct 7, 2021
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
Prev Previous commit
Next Next commit
Handle callConstructor
  • Loading branch information
liufengyun committed Oct 7, 2021
commit 111ac870914134706129fa4400523942b45dae9c
18 changes: 15 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/init/Semantic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ object Semantic {
def hasField(f: Symbol) = fields.contains(f)
}

/** Abstract heap stores abstract warm objects
/** Abstract heap stores abstract objects
*
* The heap serves as cache of summaries for warm objects and is shared for checking all classes.
*
* The fact that objects of `ThisRef` are stored in heap is just an engineering convenience.
* Technically, we can also store the object directly in `ThisRef`.
*/
object Heap {
class Heap(private var map: Map[Ref, Objekt]) {
Expand Down Expand Up @@ -322,6 +325,9 @@ object Semantic {
def call(meth: Symbol, args: List[ArgInfo], superType: Type, source: Tree): Contextual[Result] =
value.call(meth, args, superType, source) ++ errors

def callConstructor(ctor: Symbol, args: List[ArgInfo], source: Tree): Contextual[Result] =
value.callConstructor(ctor, args, source) ++ errors

def instantiate(klass: ClassSymbol, ctor: Symbol, args: List[ArgInfo], source: Tree): Contextual[Result] =
value.instantiate(klass, ctor, args, source) ++ errors
}
Expand Down Expand Up @@ -934,7 +940,10 @@ object Semantic {

case Select(qual, _) =>
val res = eval(qual, thisV, klass) ++ errors
res.call(ref.symbol, args, superType = NoType, source = expr)
if ref.symbol.isConstructor then
res.callConstructor(ref.symbol, args, source = expr)
else
res.call(ref.symbol, args, superType = NoType, source = expr)

case id: Ident =>
id.tpe match
Expand All @@ -946,7 +955,10 @@ object Semantic {
thisValue2.call(id.symbol, args, superType = NoType, expr, needResolve = false)
case TermRef(prefix, _) =>
val res = cases(prefix, thisV, klass, id) ++ errors
res.call(id.symbol, args, superType = NoType, source = expr)
if id.symbol.isConstructor then
res.callConstructor(id.symbol, args, source = expr)
else
res.call(id.symbol, args, superType = NoType, source = expr)

case Select(qualifier, name) =>
val qualRes = eval(qualifier, thisV, klass)
Expand Down