File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -81,4 +81,9 @@ object Mode {
81
81
val ReadPositions = newMode(16 , " ReadPositions" )
82
82
83
83
val PatternOrType = Pattern | Type
84
+
85
+ /** We are elaborating the fully qualified name of a package clause.
86
+ * In this case, identifiers should never be imported.
87
+ */
88
+ val InPackageClauseName = newMode(17 , " InPackageClauseName" )
84
89
}
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
95
95
def typedIdent (tree : untpd.Ident , pt : Type )(implicit ctx : Context ): Tree = track(" typedIdent" ) {
96
96
val refctx = ctx
97
97
val name = tree.name
98
+ val noImports = ctx.mode.is(Mode .InPackageClauseName )
98
99
99
100
/** Method is necessary because error messages need to bind to
100
101
* to typedIdent's context which is lost in nested calls to findRef
@@ -240,7 +241,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
240
241
241
242
/** Would import of kind `prec` be not shadowed by a nested higher-precedence definition? */
242
243
def isPossibleImport (prec : Int )(implicit ctx : Context ) =
243
- prevPrec < prec || prevPrec == prec && (prevCtx.scope eq ctx.scope)
244
+ ! noImports &&
245
+ (prevPrec < prec || prevPrec == prec && (prevCtx.scope eq ctx.scope))
244
246
245
247
@ tailrec def loop (implicit ctx : Context ): Type = {
246
248
if (ctx.scope == null ) previous
@@ -1330,7 +1332,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1330
1332
}
1331
1333
1332
1334
def typedPackageDef (tree : untpd.PackageDef )(implicit ctx : Context ): Tree = track(" typedPackageDef" ) {
1333
- val pid1 = typedExpr(tree.pid, AnySelectionProto )
1335
+ val pid1 = typedExpr(tree.pid, AnySelectionProto )(ctx.addMode( Mode . InPackageClauseName ))
1334
1336
val pkg = pid1.symbol
1335
1337
val packageContext =
1336
1338
if (pkg is Package ) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree)
Original file line number Diff line number Diff line change
1
+ package util .util
2
+
3
+ class C
You can’t perform that action at this time.
0 commit comments