Skip to content

Commit a393925

Browse files
authored
Merge branch 'main' into en-migrate-main
2 parents 48eba1c + 72acaef commit a393925

File tree

20 files changed

+164
-56
lines changed

20 files changed

+164
-56
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
351351
}
352352
else parents
353353
val cls = newNormalizedClassSymbol(owner, tpnme.ANON_CLASS, Synthetic | Final, parents1,
354-
newScope, coord = fns.map(_.span).reduceLeft(_ union _))
354+
coord = fns.map(_.span).reduceLeft(_ union _))
355355
val constr = newConstructor(cls, Synthetic, Nil, Nil).entered
356356
def forwarder(fn: TermSymbol, name: TermName) = {
357357
val fwdMeth = fn.copy(cls, name, Synthetic | Method | Final).entered.asTerm

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ object Contexts {
714714

715715
def withNotNullInfos(infos: List[NotNullInfo]): Context =
716716
if c.notNullInfos eq infos then c else c.fresh.setNotNullInfos(infos)
717+
718+
def relaxedOverrideContext: Context =
719+
c.withModeBits(c.mode &~ Mode.SafeNulls | Mode.RelaxedOverriding)
717720
end ops
718721

719722
// TODO: Fix issue when converting ModeChanges and FreshModeChanges to extension givens

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ object Symbols {
567567
name: TypeName,
568568
flags: FlagSet,
569569
parentTypes: List[Type],
570-
decls: Scope,
571570
selfInfo: Type = NoType,
572571
privateWithin: Symbol = NoSymbol,
573572
coord: Coord = NoCoord,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
786786
case AndType(tp1, tp2) => isNullable(tp1) && isNullable(tp2)
787787
case OrType(tp1, tp2) => isNullable(tp1) || isNullable(tp2)
788788
case _ => false
789-
789+
790790
val sym1 = tp1.symbol
791791
(sym1 eq NothingClass) && tp2.isValueTypeOrLambda ||
792792
(sym1 eq NullClass) && isNullable(tp2)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,7 @@ object Types {
11151115
*/
11161116
def matches(that: Type)(using Context): Boolean = {
11171117
record("matches")
1118-
val overrideCtx = if ctx.explicitNulls
1119-
then ctx.retractMode(Mode.SafeNulls).addMode(Mode.RelaxedOverriding)
1120-
else ctx
1118+
val overrideCtx = if ctx.explicitNulls then ctx.relaxedOverrideContext else ctx
11211119
TypeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)(using overrideCtx)
11221120
}
11231121

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ object Scanners {
265265
val next = newTokenData
266266
private val prev = newTokenData
267267

268-
/** The current region. This is initially an Indented region with indentation width. */
268+
/** The current region. This is initially an Indented region with zero indentation width. */
269269
var currentRegion: Region = Indented(IndentWidth.Zero, Set(), EMPTY, null)
270270

271271
// Get next token ------------------------------------------------------------
@@ -434,8 +434,8 @@ object Scanners {
434434
&& !migrateTo3
435435
&& !noindentSyntax
436436

437-
/** The indentation width of the given offset */
438-
def indentWidth(offset: Offset): IndentWidth = {
437+
/** The indentation width of the given offset. */
438+
def indentWidth(offset: Offset): IndentWidth =
439439
import IndentWidth.{Run, Conc}
440440
def recur(idx: Int, ch: Char, n: Int, k: IndentWidth => IndentWidth): IndentWidth =
441441
if (idx < 0) k(Run(ch, n))
@@ -452,7 +452,7 @@ object Scanners {
452452
else recur(idx - 1, ' ', 0, identity)
453453
}
454454
recur(offset - 1, ' ', 0, identity)
455-
}
455+
end indentWidth
456456

457457
/** Handle newlines, possibly inserting an INDENT, OUTDENT, NEWLINE, or NEWLINES token
458458
* in front of the current token. This depends on whether indentation is significant or not.
@@ -521,6 +521,7 @@ object Scanners {
521521
lastWidth = r.width
522522
newlineIsSeparating = lastWidth <= nextWidth || r.isOutermost
523523
indentPrefix = r.prefix
524+
case _: InString => ()
524525
case r =>
525526
indentIsSignificant = indentSyntax
526527
r.proposeKnownWidth(nextWidth, lastToken)
@@ -1422,7 +1423,7 @@ object Scanners {
14221423
nextToken()
14231424
currentRegion = topLevelRegion(indentWidth(offset))
14241425
}
1425-
// end Scanner
1426+
end Scanner
14261427

14271428
/** A Region indicates what encloses the current token. It can be one of the following
14281429
*

compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ExpandSAMs extends MiniPhase:
129129
val parents = List(
130130
defn.AbstractPartialFunctionClass.typeRef.appliedTo(anonTpe.firstParamTypes.head, anonTpe.resultType),
131131
defn.SerializableType)
132-
val pfSym = newNormalizedClassSymbol(anonSym.owner, tpnme.ANON_CLASS, Synthetic | Final, parents, newScope, coord = tree.span)
132+
val pfSym = newNormalizedClassSymbol(anonSym.owner, tpnme.ANON_CLASS, Synthetic | Final, parents, coord = tree.span)
133133

134134
def overrideSym(sym: Symbol) = sym.copy(
135135
owner = pfSym,

compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object OverridingPairs:
221221
// releaxed override check for explicit nulls if one of the symbols is Java defined,
222222
// force `Null` to be a subtype of non-primitive value types during override checking.
223223
val overrideCtx = if ctx.explicitNulls && (member.is(JavaDefined) || other.is(JavaDefined))
224-
then ctx.retractMode(Mode.SafeNulls).addMode(Mode.RelaxedOverriding) else ctx
224+
then ctx.relaxedOverrideContext else ctx
225225
member.name.is(DefaultGetterName) // default getters are not checked for compatibility
226226
|| memberTp.overrides(otherTp,
227227
member.matchNullaryLoosely || other.matchNullaryLoosely || fallBack

compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ object ResolveSuper {
114114
val otherTp = other.asSeenFrom(base.typeRef).info
115115
val accTp = acc.asSeenFrom(base.typeRef).info
116116
// Since the super class can be Java defined,
117-
// we use releaxed overriding check for explicit nulls if one of the symbols is Java defined.
117+
// we use relaxed overriding check for explicit nulls if one of the symbols is Java defined.
118118
// This forces `Null` to be a subtype of non-primitive value types during override checking.
119119
val overrideCtx = if ctx.explicitNulls && (sym.is(JavaDefined) || acc.is(JavaDefined))
120-
then ctx.retractMode(Mode.SafeNulls).addMode(Mode.RelaxedOverriding) else ctx
120+
then ctx.relaxedOverrideContext else ctx
121121
if !otherTp.overrides(accTp, matchLoosely = true)(using overrideCtx) then
122122
report.error(IllegalSuperAccessor(base, memberName, targetName, acc, accTp, other.symbol, otherTp), base.srcPos)
123123
bcs = bcs.tail

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,6 @@ class SpaceEngine(using Context) extends SpaceLogic {
332332

333333
private val constantNullType = ConstantType(Constant(null))
334334

335-
/** Does the given tree stand for the literal `null`? */
336-
def isNullLit(tree: Tree): Boolean = tree match {
337-
case Literal(Constant(null)) => true
338-
case _ => false
339-
}
340-
341335
override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type): Space = trace(s"atomic intersection: ${AndType(tp1, tp2).show}", debug) {
342336
// Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
343337
if !ctx.mode.is(Mode.SafeNulls) && (tp1.isNullType || tp2.isNullType) then

0 commit comments

Comments
 (0)