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 @@ -93,4 +93,9 @@ object Mode {
93
93
val ReadPositions = newMode(16 , " ReadPositions" )
94
94
95
95
val PatternOrType = Pattern | Type
96
+
97
+ /** We are elaborating the fully qualified name of a package clause.
98
+ * In this case, identifiers should never be imported.
99
+ */
100
+ val InPackageClauseName = newMode(17 , " InPackageClauseName" )
96
101
}
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
@@ -1335,7 +1337,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1335
1337
}
1336
1338
1337
1339
def typedPackageDef (tree : untpd.PackageDef )(implicit ctx : Context ): Tree = track(" typedPackageDef" ) {
1338
- val pid1 = typedExpr(tree.pid, AnySelectionProto )
1340
+ val pid1 = typedExpr(tree.pid, AnySelectionProto )(ctx.addMode( Mode . InPackageClauseName ))
1339
1341
val pkg = pid1.symbol
1340
1342
val packageContext =
1341
1343
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