Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
bc972b2
remove flow typing from main branch
noti0na1 Nov 8, 2019
b48643f
remove NonNullTermRef
noti0na1 Nov 8, 2019
d59a792
Merge pull request #43 from noti0na1/dotty-explicit-nulls-only
abeln Nov 12, 2019
763b05c
add extractor for Null ops; remove useless imports; reduce side effects
noti0na1 Nov 14, 2019
00d6607
merge upstream (Nullability Analysis without NotNull #7556)
noti0na1 Nov 15, 2019
49a35e3
rewrite widenUnion
noti0na1 Nov 15, 2019
2df913f
Update types in DottyPredef
noti0na1 Nov 15, 2019
f009775
add comments for extractors
noti0na1 Nov 20, 2019
56cdadc
optimize widenUnion
noti0na1 Nov 20, 2019
5c7c312
modify eq tests
noti0na1 Nov 20, 2019
1b28c63
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Nov 20, 2019
5ddcab6
remove redundent test
noti0na1 Nov 20, 2019
35dda77
Merge pull request #44 from noti0na1/dotty-explicit-nulls-only
noti0na1 Nov 20, 2019
334a430
fix normalizing nullable intersection type
noti0na1 Nov 21, 2019
b9cbc1f
remove JavaEnumValue from AfterLoadFlags
noti0na1 Nov 28, 2019
539051a
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Nov 28, 2019
a5b6447
Merge pull request #45 from noti0na1/dotty-explicit-nulls-only
noti0na1 Nov 28, 2019
2a8cc49
Disallow comparison between object and null
noti0na1 Nov 29, 2019
423ef59
Fix case process
noti0na1 Dec 2, 2019
708250c
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Dec 2, 2019
b12415f
Move explicit null case
noti0na1 Dec 2, 2019
a423df5
Merge pull request #46 from noti0na1/dotty-explicit-nulls-only
noti0na1 Dec 2, 2019
d12a9f1
add notNull to tree
noti0na1 Nov 20, 2019
b49aca9
add null check for paths
noti0na1 Nov 22, 2019
6a321ad
fix long stable path
noti0na1 Nov 25, 2019
b813439
better return type for Var; inline without extra val assign; better n…
noti0na1 Nov 26, 2019
ef5864e
add flow 'tests
noti0na1 Nov 29, 2019
7d40d5c
Fix isStable; fix var track in lazy val
noti0na1 Nov 29, 2019
ce606b6
Fix closure check
noti0na1 Dec 2, 2019
50b70ca
Add while, match tests
noti0na1 Dec 3, 2019
1eed780
Remove unused code
noti0na1 Dec 3, 2019
c5aab82
Update comments
noti0na1 Dec 3, 2019
465823d
Update doc, WIP
noti0na1 Dec 3, 2019
49d550e
Add flow typing to doc
noti0na1 Dec 4, 2019
bdbde1d
Simplify case
noti0na1 Dec 4, 2019
58db0c0
Refine comments
noti0na1 Dec 4, 2019
91b54aa
fix assert
noti0na1 Dec 4, 2019
61ca5e6
Add more comments and examples
noti0na1 Dec 4, 2019
46fc5cd
Merge pull request #47 from noti0na1/dotty-explicit-nulls-notNull
noti0na1 Dec 5, 2019
0230180
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Dec 5, 2019
3bb1b82
Merge pull request #48 from noti0na1/dotty-explicit-nulls-notNull
abeln Dec 5, 2019
77df754
add usedOutOfOrder
noti0na1 Dec 9, 2019
6bdb9f0
Add tests
noti0na1 Dec 10, 2019
7dc2e76
Optimize NullOps; add helper functions
noti0na1 Dec 11, 2019
0acba32
Edit comments
noti0na1 Dec 11, 2019
dea268a
Add suggested NotNull annots
noti0na1 Dec 12, 2019
d26b424
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Dec 12, 2019
a8f3dc1
Merge pull request #49 from noti0na1/dotty-explicit-nulls-notNull
noti0na1 Dec 12, 2019
2f42d1b
Update comments
noti0na1 Dec 12, 2019
1c15bef
Merge pull request #50 from noti0na1/dotty-explicit-nulls-notNull
noti0na1 Dec 12, 2019
9a3a625
Fix typos
noti0na1 Dec 13, 2019
2af339f
Merge remote-tracking branch 'upstream/master' into dotty-explicit-nu…
noti0na1 Dec 13, 2019
c41b926
Rewrite the if stat
noti0na1 Dec 13, 2019
85c0855
Merge pull request #51 from noti0na1/dotty-explicit-nulls-notNull
noti0na1 Dec 13, 2019
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
Fix typos
  • Loading branch information
noti0na1 committed Dec 13, 2019
commit 9a3a62509abcce7ca1b02ad72b4468692361042c
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/core/NullOpsDecorator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ object NullOpsDecorator {
}

val self1 = self.widenDealias
val striped = strip(self1)
if (striped ne self1) striped else self
val stripped = strip(self1)
if (stripped ne self1) stripped else self
}

/** Like `stripNull`, but removes only the `JavaNull`s. */
Expand All @@ -73,14 +73,14 @@ object NullOpsDecorator {

/** Is self (after widening and dealiasing) a type of the form `T | Null`? */
def isNullableUnion(implicit ctx: Context): Boolean = {
val striped = self.stripNull()
striped ne self
val stripped = self.stripNull()
stripped ne self
}

/** Is self (after widening and dealiasing) a type of the form `T | JavaNull`? */
def isJavaNullableUnion(implicit ctx: Context): Boolean = {
val striped = self.stripNull(true)
striped ne self
val stripped = self.stripNull(true)
stripped ne self
}
}
}
12 changes: 7 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Nullables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ object Nullables with
val refSym = ref.symbol
val refOwner = refSym.owner

@tailrec def usedWithinClosure(s: Symbol): Boolean =
@tailrec def recur(s: Symbol): Boolean =
s != NoSymbol
&& s != refOwner
&& (s.isOneOf(Lazy | Method) // not at the rhs of lazy ValDef or in a method (or lambda)
|| s.isClass // not in a class
// TODO: need to check by-name paramter
|| usedWithinClosure(s.owner))
|| recur(s.owner))

refSym.is(Mutable) // if it is immutable, we don't need to check the rest conditions
&& refOwner.isTerm
&& usedWithinClosure(curCtx.owner)
&& recur(curCtx.owner)

given treeOps: extension (tree: Tree) with

Expand Down Expand Up @@ -335,9 +335,11 @@ object Nullables with
// lhs variable is no longer trackable. We don't need to check whether the type `T`
// is correct here, as typer will check it.
tree.withNotNullInfo(NotNullInfo(Set(), Set(ref)))
else
// otherwise, we know the variable will have a non-null value
else if (curCtx.explicitNulls && ref.isNullableUnion)
// If the initial type is nullable and the assigned value is non-null,
// we add it to the NotNull
tree.withNotNullInfo(NotNullInfo(Set(ref), Set()))
else tree
case _ => tree

private val analyzedOps = Set(nme.EQ, nme.NE, nme.eq, nme.ne, nme.ZAND, nme.ZOR, nme.UNARY_!)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ class Typer extends Namer
}

/** Tries to adapt NotNullInfos from creation context to the DefTree,
* returns whether the adaption is successed. The adaption only success if the
* returns whether the adaption took place. An adaption only takes place if the
* DefTree has a symbol and it has not been completed (is not forward referenced).
*/
def adaptCreationContext(mdef: untpd.DefTree)(implicit ctx: Context): Boolean =
Expand Down