summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-01-19 13:01:31 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-01-19 13:01:31 +0100
commit3486d47508686e4b96560e176280fa9fc536fd41 (patch)
tree399425abd04da5981d0ffe6000c6414e3027e43e /src
parent6f72ed85c3882d2a8c824a41e6e42d7f33b8d1d6 (diff)
downloadscala-3486d47508686e4b96560e176280fa9fc536fd41.tar.gz
scala-3486d47508686e4b96560e176280fa9fc536fd41.tar.bz2
scala-3486d47508686e4b96560e176280fa9fc536fd41.zip
SI-6439 Avoid spurious REPL warnings about companionship
`val m` isn't a companion of `trait m`, check the pair of eponymous symbols are a ((class|trait), object) pair before emitting the warning. In order to correctly check this one a type alias is involved, `definedSymbols` must avoid normalizing through type aliases. AFAICT this is an improvement to the other clients of that Map, one such power mode progression is demonstrated at the end of the test case.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index b46d28dec3..a55f0af116 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -386,6 +386,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
oldReq <- definedNameMap get name.companionName
newSym <- req.definedSymbols get name
oldSym <- oldReq.definedSymbols get name.companionName
+ if Seq(oldSym, newSym).permutations exists { case Seq(s1, s2) => s1.isClass && s2.isModule }
} {
afterTyper(replwarn(s"warning: previously defined $oldSym is not a companion to $newSym."))
replwarn("Companions must be defined together; you may wish to use :paste mode for this.")
@@ -970,7 +971,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
// }
lazy val definedSymbols = (
termNames.map(x => x -> applyToResultMember(x, x => x)) ++
- typeNames.map(x => x -> compilerTypeOf(x).typeSymbol)
+ typeNames.map(x => x -> compilerTypeOf(x).typeSymbolDirect)
).toMap[Name, Symbol] withDefaultValue NoSymbol
lazy val typesOfDefinedTerms = mapFrom[Name, Name, Type](termNames)(x => applyToResultMember(x, _.tpe))