Skip to content

Commit f5efea1

Browse files
author
EnzeXing
committed
Add internal error in instantiate
1 parent eb5e555 commit f5efea1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,11 @@ object Objects:
876876
(Bottom, Env.NoEnv)
877877
case thisV : (Ref | Cold.type) =>
878878
if klass.owner.isClass then
879-
assert(!klass.owner.is(Flags.Package), "top-level class should have `Bottom` as outer")
880-
(thisV.widenRefOrCold(1), Env.NoEnv)
879+
if klass.owner.is(Flags.Package) then
880+
report.warning("top-level class should have `Bottom` as outer, class = " + klass.show + ", outer = " + outer.show + ", " + Trace.show, Trace.position)
881+
(Bottom, Env.NoEnv)
882+
else
883+
(thisV.widenRefOrCold(1), Env.NoEnv)
881884
else
882885
// klass.enclosingMethod returns its primary constructor
883886
Env.resolveEnv(klass.owner.enclosingMethod, thisV, summon[Env.Data]).getOrElse(Cold -> Env.NoEnv)

0 commit comments

Comments
 (0)