Skip to content

Commit ec0d1f9

Browse files
author
EnzeXing
committed
Address comments
1 parent a7eb174 commit ec0d1f9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 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)
@@ -1046,6 +1046,8 @@ class Objects(using Context @constructorOnly):
10461046
else if target.equals(defn.Predef_classOf) then
10471047
// Predef.classOf is a stub method in tasty and is replaced in backend
10481048
UnknownValue
1049+
else if target.is(Flags.JavaDefined) then
1050+
UnknownValue
10491051
else if target.hasSource then
10501052
val cls = target.owner.enclosingClass.asClass
10511053
val ddef = target.defTree.asInstanceOf[DefDef]
@@ -1806,6 +1808,7 @@ class Objects(using Context @constructorOnly):
18061808
val toSeqResTp = resultTp.memberInfo(selectors.last).finalResultType
18071809
evalSeqPatterns(toSeqRes, toSeqResTp, elemTp, seqPats)
18081810
end if
1811+
// TODO: refactor the code of product sequence match, avoid passing NoType to parameter elemTp in evalSeqPatterns
18091812

18101813
else
18111814
// distribute unapply to patterns

0 commit comments

Comments
 (0)