diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-30 15:51:45 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-30 15:55:31 -0800 |
commit | fd6fe4e428948cbbc3feb5ee186f784e0205d697 (patch) | |
tree | 81aaa12a5136a2885b70578214fe0278cab59be4 | |
parent | d499db3800b6460cfd575e650953980211d4026b (diff) | |
download | scala-fd6fe4e428948cbbc3feb5ee186f784e0205d697.tar.gz scala-fd6fe4e428948cbbc3feb5ee186f784e0205d697.tar.bz2 scala-fd6fe4e428948cbbc3feb5ee186f784e0205d697.zip |
Fix access to empty package from the repl.
It seems that way back in f5c336d566 three months ago I
booched the repl's ability to get at the empty package.
I've noticed this a hundred times but strangely it has not
been reported by anyone else. Perhaps you are all religious
package users. In any case, it is back.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 | ||||
-rw-r--r-- | test/files/run/repl-empty-package.check | 7 | ||||
-rw-r--r-- | test/files/run/repl-empty-package/s_1.scala | 3 | ||||
-rw-r--r-- | test/files/run/repl-empty-package/s_2.scala | 5 |
4 files changed, 18 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 994339a028..c5484ca44f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3981,7 +3981,8 @@ trait Typers extends Adaptations with Tags { // Lookup in the given qualifier. Used in last-ditch efforts by typedIdent and typedSelect. def lookupInRoot(name: Name): Symbol = lookupInOwner(rootMirror.RootClass, name) - def lookupInEmpty(name: Name): Symbol = lookupInOwner(rootMirror.EmptyPackageClass, name) + def lookupInEmpty(name: Name): Symbol = rootMirror.EmptyPackageClass.info member name + def lookupInQualifier(qual: Tree, name: Name): Symbol = ( if (name == nme.ERROR || qual.tpe.widen.isErroneous) NoSymbol @@ -4775,7 +4776,7 @@ trait Typers extends Adaptations with Tags { * (2) Change imported symbols to selections */ def typedIdent(tree: Tree, name: Name): Tree = { - // setting to enable unqualified idents in empty package + // setting to enable unqualified idents in empty package (used by the repl) def inEmptyPackage = if (settings.exposeEmptyPackage.value) lookupInEmpty(name) else NoSymbol def issue(err: AbsTypeError) = { diff --git a/test/files/run/repl-empty-package.check b/test/files/run/repl-empty-package.check new file mode 100644 index 0000000000..ecf79c2c6d --- /dev/null +++ b/test/files/run/repl-empty-package.check @@ -0,0 +1,7 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> println(Bippy.bippy) +bippy! + +scala> diff --git a/test/files/run/repl-empty-package/s_1.scala b/test/files/run/repl-empty-package/s_1.scala new file mode 100644 index 0000000000..b59d16b338 --- /dev/null +++ b/test/files/run/repl-empty-package/s_1.scala @@ -0,0 +1,3 @@ +object Bippy { + def bippy = "bippy!" +} diff --git a/test/files/run/repl-empty-package/s_2.scala b/test/files/run/repl-empty-package/s_2.scala new file mode 100644 index 0000000000..512e6dd382 --- /dev/null +++ b/test/files/run/repl-empty-package/s_2.scala @@ -0,0 +1,5 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = "println(Bippy.bippy)" +} |