Skip to content

Commit 168565f

Browse files
author
EnzeXing
committed
Adding warnings for selecting and assigning arrays
1 parent cd808e9 commit 168565f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ object Objects:
795795
report.warning("[Internal error] unexpected tree in selecting a function, fun = " + fun.code.show + Trace.show, fun.code)
796796
Bottom
797797

798+
case arr: OfArray =>
799+
report.warning("[Internal error] unexpected tree in selecting an array, array = " + arr.show + Trace.show, Trace.position)
800+
Bottom
801+
798802
case Bottom =>
799803
if field.isStaticObject then ObjectRef(field.moduleClass.asClass)
800804
else Bottom
@@ -815,6 +819,9 @@ object Objects:
815819
case fun: Fun =>
816820
report.warning("[Internal error] unexpected tree in assignment, fun = " + fun.code.show + Trace.show, Trace.position)
817821

822+
case arr: OfArray =>
823+
report.warning("[Internal error] unexpected tree in assignment, array = " + arr.show + Trace.show, Trace.position)
824+
818825
case Cold =>
819826
report.warning("Assigning to cold aliases is forbidden. Calling trace:\n" + Trace.show, Trace.position)
820827

@@ -851,7 +858,7 @@ object Objects:
851858
report.warning("[Internal error] unexpected outer in instantiating a class, outer = " + outer.show + ", class = " + klass.show + ", " + Trace.show, Trace.position)
852859
Bottom
853860

854-
case _: Ref | _ : Cold.type | _ : Bottom.type =>
861+
case outer: (Ref | Cold.type | Bottom.type) =>
855862
if klass == defn.ArrayClass then
856863
val arr = OfArray(State.currentObject, summon[Regions.Data])
857864
Heap.write(arr.addr, Bottom)
@@ -931,7 +938,7 @@ object Objects:
931938
case Cold =>
932939
report.warning("Calling cold by-name alias. Call trace: \n" + Trace.show, Trace.position)
933940
Bottom
934-
case _: ValueSet | _: Ref =>
941+
case _: ValueSet | _: Ref | _: OfArray =>
935942
report.warning("[Internal error] Unexpected by-name value " + value.show + ". Calling trace:\n" + Trace.show, Trace.position)
936943
Bottom
937944
else

project/Build.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ object Build {
196196
"-deprecation",
197197
"-unchecked",
198198
//"-Wconf:cat=deprecation&msg=Unsafe:s", // example usage
199-
// "-Xfatal-warnings", // -Werror in modern usage
199+
"-Xfatal-warnings", // -Werror in modern usage
200200
"-encoding", "UTF8",
201201
"-language:implicitConversions",
202202
),
@@ -810,9 +810,6 @@ object Build {
810810
)
811811
},
812812

813-
// Note: bench/profiles/projects.yml should be updated accordingly.
814-
Compile / scalacOptions ++= Seq("-Yexplicit-nulls", "-Ysafe-init", "-Ysafe-init-global"),
815-
816813
repl := (Compile / console).value,
817814
Compile / console / scalacOptions := Nil, // reset so that we get stock REPL behaviour! E.g. avoid -unchecked being enabled
818815
)

0 commit comments

Comments
 (0)