Skip to content

Commit 3292ed8

Browse files
committed
Tweaks
- Use Eql derivation in Namer - Use end markers in Nullables - Fix a link in overview doc
1 parent 06a118e commit 3292ed8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ object Names {
2525
def toTermName: TermName
2626
}
2727

28-
implicit def eqName: Eql[Name, Name] = Eql.derived
29-
3028
/** A common superclass of Name and Symbol. After bootstrap, this should be
3129
* just the type alias Name | Symbol
3230
*/
@@ -37,7 +35,7 @@ object Names {
3735
* in a name table. A derived term name adds a tag, and possibly a number
3836
* or a further simple name to some other name.
3937
*/
40-
abstract class Name extends Designator with PreName {
38+
abstract class Name extends Designator, PreName derives Eql {
4139

4240
/** A type for names of the same kind as this name */
4341
type ThisName <: Name

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ object Nullables:
189189
val mutables = infos.foldLeft(Set[TermRef]())((ms, info) =>
190190
ms.union(info.asserted.filter(_.symbol.is(Mutable))))
191191
infos.extendWith(NotNullInfo(Set(), mutables))
192-
// end notNullInfoOps
192+
end notNullInfoOps
193193

194194
extension refOps on (ref: TermRef):
195195

@@ -244,6 +244,7 @@ object Nullables:
244244
refSym.is(Mutable) // if it is immutable, we don't need to check the rest conditions
245245
&& refOwner.isTerm
246246
&& recur(ctx.owner)
247+
end refOps
247248

248249
extension treeOps on (tree: Tree):
249250

@@ -334,6 +335,7 @@ object Nullables:
334335
traverseChildren(tree)
335336
tree.computeNullable()
336337
}.traverse(tree)
338+
end treeOps
337339

338340
extension assignOps on (tree: Assign):
339341
def computeAssignNullable()(using Context): tree.type = tree.lhs match
@@ -351,6 +353,7 @@ object Nullables:
351353
tree.withNotNullInfo(NotNullInfo(Set(ref), Set()))
352354
else tree
353355
case _ => tree
356+
end assignOps
354357

355358
private val analyzedOps = Set(nme.EQ, nme.NE, nme.eq, nme.ne, nme.ZAND, nme.ZOR, nme.UNARY_!)
356359

@@ -444,13 +447,16 @@ object Nullables:
444447
* xs = xs.next
445448
*/
446449
def whileContext(whileSpan: Span)(using Context): Context =
450+
447451
def isRetracted(ref: TermRef): Boolean =
448452
val sym = ref.symbol
449453
sym.span.exists
450454
&& assignmentSpans.getOrElse(sym.span.start, Nil).exists(whileSpan.contains(_))
451455
&& ctx.notNullInfos.impliesNotNull(ref)
456+
452457
val retractedVars = ctx.notNullInfos.flatMap(_.asserted.filter(isRetracted)).toSet
453458
ctx.addNotNullInfo(NotNullInfo(Set(), retractedVars))
459+
end whileContext
454460

455461
/** Post process all arguments to by-name parameters by removing any not-null
456462
* info that was used when typing them. Concretely:

docs/docs/reference/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ These constructs replace existing constructs with the aim of making the language
3333
- [Trait Parameters](other-new-features/trait-parameters.md) replace [early initializers](dropped-features/early-initializers.md) with a more generally useful construct.
3434
- [Given Instances](contextual/delegates.md)
3535
replace implicit objects and defs, focussing on intent over mechanism.
36-
- [Given Clauses](contextual/given-clauses.md) replace implicit parameters, avoiding their ambiguities.
36+
- [Using Clauses](contextual/using-clauses.md) replace implicit parameters, avoiding their ambiguities.
3737
- [Extension Methods](contextual/extension-methods.md) replace implicit classes with a clearer and simpler mechanism.
3838
- [Opaque Type Aliases](other-new-features/opaques.md) replace most uses
3939
of value classes while guaranteeing absence of boxing.

0 commit comments

Comments
 (0)