summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-08-30 04:44:25 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-08-30 04:44:25 -0700
commit415639fbf6b7f1a9366e970a8850a0d735dc7a14 (patch)
tree0ddf534a466bebc80047b0eb140a3d4e5b1ff91c
parent778edaaf7bec83a28ec669521d6d679a005f1040 (diff)
parent7b6da97d683fd7ff2e3f7340e9138e615aed763a (diff)
downloadscala-415639fbf6b7f1a9366e970a8850a0d735dc7a14.tar.gz
scala-415639fbf6b7f1a9366e970a8850a0d735dc7a14.tar.bz2
scala-415639fbf6b7f1a9366e970a8850a0d735dc7a14.zip
Merge pull request #1209 from odersky/ticket/6227
Closes SI-6227
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala13
-rw-r--r--test/files/neg/t6227.check4
-rw-r--r--test/files/neg/t6227.scala6
-rw-r--r--test/files/pos/t5667.scala2
4 files changed, 23 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 77d1260564..adced9d8c9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -192,6 +192,10 @@ trait Namers extends MethodSynthesis {
if (!allowsOverload(sym)) {
val prev = scope.lookupEntry(sym.name)
if ((prev ne null) && prev.owner == scope && conflict(sym, prev.sym)) {
+ if (sym.isSynthetic || prev.sym.isSynthetic) {
+ handleSyntheticNameConflict(sym, prev.sym)
+ handleSyntheticNameConflict(prev.sym, sym)
+ }
DoubleDefError(sym, prev.sym)
sym setInfo ErrorType
scope unlink prev.sym // let them co-exist...
@@ -202,6 +206,14 @@ trait Namers extends MethodSynthesis {
scope enter sym
}
+ /** Logic to handle name conflicts of synthetically generated symbols
+ * We handle right now: t6227
+ */
+ def handleSyntheticNameConflict(sym1: Symbol, sym2: Symbol) = {
+ if (sym1.isImplicit && sym1.isMethod && sym2.isModule && sym2.companionClass.isCaseClass)
+ validate(sym2.companionClass)
+ }
+
def enterSym(tree: Tree): Context = {
def dispatch() = {
var returnContext = this.context
@@ -1390,6 +1402,7 @@ trait Namers extends MethodSynthesis {
fail(ImplicitAtToplevel)
}
if (sym.isClass) {
+ checkNoConflict(IMPLICIT, CASE)
if (sym.isAnyOverride && !sym.hasFlag(TRAIT))
fail(OverrideClass)
} else {
diff --git a/test/files/neg/t6227.check b/test/files/neg/t6227.check
new file mode 100644
index 0000000000..5e3c636712
--- /dev/null
+++ b/test/files/neg/t6227.check
@@ -0,0 +1,4 @@
+t6227.scala:2: error: illegal combination of modifiers: implicit and case for: class IntOps
+ implicit case class IntOps( i: Int ) {
+ ^
+one error found
diff --git a/test/files/neg/t6227.scala b/test/files/neg/t6227.scala
new file mode 100644
index 0000000000..46416839d1
--- /dev/null
+++ b/test/files/neg/t6227.scala
@@ -0,0 +1,6 @@
+object Test {
+ implicit case class IntOps( i: Int ) {
+ def twice = i * 2
+ }
+}
+
diff --git a/test/files/pos/t5667.scala b/test/files/pos/t5667.scala
index 513de5b663..353eec93d6 100644
--- a/test/files/pos/t5667.scala
+++ b/test/files/pos/t5667.scala
@@ -1,6 +1,4 @@
object Main {
implicit class C(val s: String) extends AnyVal
implicit class C2(val s: String) extends AnyRef
-
- implicit case class Foo(i: Int)
}