File tree 5 files changed +39
-4
lines changed
5 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -1060,7 +1060,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
1060
1060
if (sym.isImport)
1061
1061
sym.infoOrCompleter match {
1062
1062
case info : Namer # Completer => return info.original.show
1063
- case info : ImportType => return s " import $info.expr.show "
1063
+ case info : ImportType => return s " import ${ info.expr.show} "
1064
1064
case _ =>
1065
1065
}
1066
1066
def name =
Original file line number Diff line number Diff line change @@ -439,7 +439,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
439
439
if (curImport.nn.unimported ne NoSymbol ) unimported += curImport.nn.unimported
440
440
if (curOwner.is(Package ) && curImport != null && curImport.isRootImport && previous.exists)
441
441
previous // no more conflicts possible in this case
442
- else if (isPossibleImport(NamedImport ) && (curImport nen outer.importInfo)) {
442
+ else if isPossibleImport(NamedImport ) &&
443
+ ((curImport nen outer.importInfo)
444
+ || curImport != null
445
+ && curImport.isRootImport
446
+ && curImport.site.termSymbol.name.isReplWrapperName
447
+ )
448
+ then
443
449
val namedImp = namedImportRef(curImport.uncheckedNN)
444
450
if (namedImp.exists)
445
451
recurAndCheckNewOrShadowed(namedImp, NamedImport , ctx)(using outer)
@@ -456,7 +462,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
456
462
updateUnimported()
457
463
loop(ctx)(using outer)
458
464
}
459
- }
460
465
else loop(ctx)(using outer)
461
466
}
462
467
}
Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ class ReplCompiler extends Compiler:
62
62
}
63
63
64
64
val rootCtx = super .rootContext.fresh
65
- .setOwner(defn.EmptyPackageClass )
66
65
.withRootImports
67
66
(state.validObjectIndexes).foldLeft(rootCtx)((ctx, id) =>
68
67
importPreviousRun(id)(using ctx))
Original file line number Diff line number Diff line change @@ -32,6 +32,20 @@ class ShadowingBatchTests extends ErrorMessagesTest:
32
32
ictx.setSetting(classpath, classpath.value + File .pathSeparator + dir.jpath.toAbsolutePath)
33
33
}
34
34
35
+ @ Test def io =
36
+ val lib = """ |package io.foo
37
+ |
38
+ |object Bar {
39
+ | def baz: Int = 42
40
+ |}
41
+ |""" .stripMargin
42
+ val app = """ |object Main:
43
+ | def main(args: Array[String]): Unit =
44
+ | println(io.foo.Bar.baz)
45
+ |""" .stripMargin
46
+ checkMessages(lib).expectNoErrors
47
+ checkMessages(app).expectNoErrors
48
+
35
49
@ Test def file =
36
50
checkMessages(" class C(val c: Int)" ).expectNoErrors
37
51
checkMessages(" object rsline1 {\n def line1 = new C().c\n }" ).expect { (_, msgs) =>
Original file line number Diff line number Diff line change @@ -76,6 +76,18 @@ class ShadowingTests extends ReplTest(options = ShadowingTests.options):
76
76
Files .delete(file)
77
77
end compileShadowed
78
78
79
+ @ Test def io = shadowedScriptedTest(name = " io" ,
80
+ shadowed = """ |package io.foo
81
+ |
82
+ |object Bar {
83
+ | def baz: Int = 42
84
+ |}
85
+ |""" .stripMargin,
86
+ script = """ |scala> io.foo.Bar.baz
87
+ |val res0: Int = 42
88
+ |""" .stripMargin
89
+ )
90
+
79
91
@ Test def i7635 = shadowedScriptedTest(name = " <i7635>" ,
80
92
shadowed = " class C(val c: Int)" ,
81
93
script =
@@ -129,6 +141,11 @@ class ShadowingTests extends ReplTest(options = ShadowingTests.options):
129
141
ShadowingTests .createSubDir(" util" )
130
142
testScript(name = " <shadow-subdir-util>" ,
131
143
""" |scala> import util.Try
144
+ |-- [E008] Not Found Error: -----------------------------------------------------
145
+ |1 | import util.Try
146
+ | | ^^^
147
+ | | value Try is not a member of util
148
+ |1 error found
132
149
|
133
150
|scala> object util { class Try { override def toString = "you've gotta try!" } }
134
151
|// defined object util
You can’t perform that action at this time.
0 commit comments