File tree 2 files changed +12
-2
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -166,15 +166,19 @@ class Typer extends Namer
166
166
* but then we'd have to give up the fiction that a compilation unit consists of
167
167
* a single tree (because a source file may have both toplevel classes which go
168
168
* into the empty package and package definitions, which would have to stay outside).
169
- * Since the concept of a single tree per compilation unit is known to many
169
+ * Since the principle of a single tree per compilation unit is assumed by many
170
170
* tools, we did not want to take that step.
171
171
*/
172
172
def qualifies (denot : Denotation ): Boolean =
173
173
reallyExists(denot)
174
174
&& (! pt.isInstanceOf [UnapplySelectionProto ]
175
175
|| denot.hasAltWith(sd => ! sd.symbol.is(Method , butNot = Accessor )))
176
176
&& ! denot.symbol.is(PackageClass )
177
- && (! denot.symbol.maybeOwner.isEmptyPackage || ctx.owner.enclosingPackageClass.isEmptyPackage)
177
+ && {
178
+ var owner = denot.symbol.maybeOwner
179
+ if owner.isPackageObject then owner = owner.owner
180
+ ! owner.isEmptyPackage || ctx.owner.enclosingPackageClass.isEmptyPackage
181
+ }
178
182
179
183
/** Find the denotation of enclosing `name` in given context `ctx`.
180
184
* @param previous A denotation that was found in a more deeply nested scope,
Original file line number Diff line number Diff line change
1
+ // was previously ok in one compilation unit
2
+ def f22 = " hello, world"
3
+
4
+ package p {
5
+ @ main def m = println(f22) // error
6
+ }
You can’t perform that action at this time.
0 commit comments