Skip to content

Commit 4b97d25

Browse files
EnzeXingolhotak
authored andcommitted
Address comments
1 parent 6e110f5 commit 4b97d25

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ class Objects(using Context @constructorOnly):
151151
def hasVar(sym: Symbol)(using Heap.MutableData): Boolean = Heap.containsVal(this, sym)
152152

153153
def initVal(field: Symbol, value: Value)(using Context, Heap.MutableData) = log("Initialize " + field.show + " = " + value + " for " + this, printer) {
154-
assert(field.is(Flags.Param) || !field.is(Flags.Mutable), "Field is mutable: " + field.show)
154+
assert(!field.is(Flags.Mutable), "Field is mutable: " + field.show)
155155
Heap.writeJoinVal(this, field, value)
156156
}
157157

158158
def initVar(field: Symbol, value: Value)(using Context, Heap.MutableData) = log("Initialize " + field.show + " = " + value + " for " + this, printer) {
159-
assert(field.is(Flags.Mutable, butNot = Flags.Param), "Field is not mutable: " + field.show)
159+
assert(field.is(Flags.Mutable), "Field is not mutable: " + field.show)
160160
Heap.writeJoinVal(this, field, value)
161161
}
162162

@@ -421,12 +421,12 @@ class Objects(using Context @constructorOnly):
421421
def hasVar(sym: Symbol)(using EnvMap.EnvMapMutableData): Boolean = EnvMap.containsVal(this, sym)
422422

423423
def initVal(field: Symbol, value: Value)(using Context, EnvMap.EnvMapMutableData) = log("Initialize " + field.show + " = " + value + " for " + this, printer) {
424-
assert(field.is(Flags.Param) || !field.is(Flags.Mutable), "Field is mutable: " + field.show)
424+
assert(!field.is(Flags.Mutable), "Field is mutable: " + field.show)
425425
EnvMap.writeJoinVal(this, field, value)
426426
}
427427

428428
def initVar(field: Symbol, value: Value)(using Context, EnvMap.EnvMapMutableData) = log("Initialize " + field.show + " = " + value + " for " + this, printer) {
429-
assert(field.is(Flags.Mutable, butNot = Flags.Param), "Field is not mutable: " + field.show)
429+
assert(field.is(Flags.Mutable), "Field is not mutable: " + field.show)
430430
EnvMap.writeJoinVal(this, field, value)
431431
}
432432

@@ -527,7 +527,7 @@ class Objects(using Context @constructorOnly):
527527
_of(Map.empty, byNameParam, thisV, outerEnv)
528528

529529
def setLocalVal(x: Symbol, value: Value)(using scope: Scope, ctx: Context, heap: Heap.MutableData, envMap: EnvMap.EnvMapMutableData): Unit =
530-
assert(x.is(Flags.Param) || !x.is(Flags.Mutable), "Only local immutable variable allowed")
530+
assert(!x.isOneOf(Flags.Param | Flags.Mutable), "Only local immutable variable allowed")
531531
scope match
532532
case env: EnvRef =>
533533
env.initVal(x, value)
@@ -1806,6 +1806,7 @@ class Objects(using Context @constructorOnly):
18061806
val toSeqResTp = resultTp.memberInfo(selectors.last).finalResultType
18071807
evalSeqPatterns(toSeqRes, toSeqResTp, elemTp, seqPats)
18081808
end if
1809+
// TODO: refactor the code of product sequence match, avoid passing NoType to parameter elemTp in evalSeqPatterns
18091810

18101811
else
18111812
// distribute unapply to patterns

compiler/src/dotty/tools/dotc/transform/init/Util.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Trace.*
1717
object Util:
1818
/** Exception used for errors encountered when reading TASTy. */
1919
case class TastyTreeException(msg: String) extends RuntimeException(msg)
20-
20+
2121
/** Utility definition used for better error-reporting of argument errors */
2222
case class TraceValue[T](value: T, trace: Trace)
2323

@@ -96,7 +96,7 @@ object Util:
9696
else sym.matchingMember(cls.appliedRef)
9797

9898
extension (sym: Symbol)
99-
def hasSource(using Context): Boolean = !sym.defTree.isEmpty
99+
def hasSource(using Context): Boolean = !sym.is(Flags.JavaDefined) && !sym.defTree.isEmpty
100100

101101
def isStaticObject(using Context) =
102102
sym.is(Flags.Module, butNot = Flags.Package) && sym.isStatic

0 commit comments

Comments
 (0)