diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 20 | ||||
-rw-r--r-- | test/files/neg/t200.check | 2 | ||||
-rw-r--r-- | test/files/neg/t2779.check | 2 | ||||
-rw-r--r-- | test/files/neg/t278.check | 2 | ||||
-rw-r--r-- | test/files/neg/t591.check | 2 | ||||
-rw-r--r-- | test/files/neg/t800.check | 6 | ||||
-rw-r--r-- | test/files/neg/t960.check | 4 | ||||
-rw-r--r-- | test/pending/run/t4511b.scala | 25 |
8 files changed, 49 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index ea5223e32f..140df53816 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -624,11 +624,21 @@ trait ContextErrors { setError(tree) } - // checkNoDoubleDefs... - def DefDefinedTwiceError(sym0: Symbol, sym1: Symbol) = - issueSymbolTypeError(sym0, sym1+" is defined twice"+ - {if(!settings.debug.value) "" else " in "+context0.unit}+ - {if (sym0.isMacro && sym1.isMacro) " \n(note that macros cannot be overloaded)" else ""}) + // checkNoDoubleDefs... + // @PP: I hacked the filename in (context0.unit) to work around SI-4893. It would be + // much better if every symbol could offer some idea of where it came from, else + // the obviously untrue claim that something has been defined twice can only frustrate. + // There's no direct test because partest doesn't work, but to reproduce, separately + // compile the next two lines: + // package object foo { val x: Class[_] = null } + // package foo + def DefDefinedTwiceError(sym0: Symbol, sym1: Symbol) = { + val isBug = sym0.isAbstractType && sym1.isAbstractType && (sym0.name startsWith "_$") + issueSymbolTypeError(sym0, sym1+" is defined twice in " + context0.unit + + ( if (sym0.isMacro && sym1.isMacro) "\n(note that macros cannot be overloaded)" else "" ) + + ( if (isBug) "\n(this error is likely due to a bug in the scala compiler involving wildcards in package objects)" else "" ) + ) + } // cyclic errors def CyclicAliasingOrSubtypingError(errPos: Position, sym0: Symbol) = diff --git a/test/files/neg/t200.check b/test/files/neg/t200.check index 78701f8533..3ef6665fe5 100644 --- a/test/files/neg/t200.check +++ b/test/files/neg/t200.check @@ -1,4 +1,4 @@ -t200.scala:7: error: method foo is defined twice +t200.scala:7: error: method foo is defined twice in t200.scala def foo: Int; ^ one error found diff --git a/test/files/neg/t2779.check b/test/files/neg/t2779.check index 4f94a780a1..d642541e3e 100644 --- a/test/files/neg/t2779.check +++ b/test/files/neg/t2779.check @@ -1,4 +1,4 @@ -t2779.scala:16: error: method f is defined twice +t2779.scala:16: error: method f is defined twice in t2779.scala override def f = List(M1) ^ one error found diff --git a/test/files/neg/t278.check b/test/files/neg/t278.check index 675ef910ee..0c2dfeb67a 100644 --- a/test/files/neg/t278.check +++ b/test/files/neg/t278.check @@ -4,7 +4,7 @@ t278.scala:5: error: overloaded method value a with alternatives: does not take type parameters println(a[A]) ^ -t278.scala:4: error: method a is defined twice +t278.scala:4: error: method a is defined twice in t278.scala def a = (p:A) => () ^ two errors found diff --git a/test/files/neg/t591.check b/test/files/neg/t591.check index 434c2dd002..5cdeebf079 100644 --- a/test/files/neg/t591.check +++ b/test/files/neg/t591.check @@ -1,4 +1,4 @@ -t591.scala:38: error: method input_= is defined twice +t591.scala:38: error: method input_= is defined twice in t591.scala def input_=(in : Input) = {} ^ one error found diff --git a/test/files/neg/t800.check b/test/files/neg/t800.check index 4bfba5420b..44c316a95b 100644 --- a/test/files/neg/t800.check +++ b/test/files/neg/t800.check @@ -1,13 +1,13 @@ t800.scala:4: error: qualification is already defined as value qualification val qualification = false; ^ -t800.scala:8: error: method qualification is defined twice +t800.scala:8: error: method qualification is defined twice in t800.scala val qualification = false; ^ -t800.scala:12: error: value qualification is defined twice +t800.scala:12: error: value qualification is defined twice in t800.scala var qualification = false; ^ -t800.scala:16: error: method qualification is defined twice +t800.scala:16: error: method qualification is defined twice in t800.scala var qualification = false; ^ four errors found diff --git a/test/files/neg/t960.check b/test/files/neg/t960.check index 4cc76d3602..603b1cb032 100644 --- a/test/files/neg/t960.check +++ b/test/files/neg/t960.check @@ -7,7 +7,7 @@ match argument types (List[a]) t960.scala:22: error: cannot resolve overloaded unapply case List(x, xs) => 7 ^ -t960.scala:12: error: method unapply is defined twice +t960.scala:12: error: method unapply is defined twice in t960.scala def unapply[a](xs: List[a]): Option[Null] = xs match { ^ -three errors found
\ No newline at end of file +three errors found diff --git a/test/pending/run/t4511b.scala b/test/pending/run/t4511b.scala new file mode 100644 index 0000000000..3337fb3203 --- /dev/null +++ b/test/pending/run/t4511b.scala @@ -0,0 +1,25 @@ +import scala.{specialized => spec} + +class Interval[@spec(Int) T](high:T) + +class X1[@spec(Int) T](interval:Interval[T]) { val x = interval } +class Y1[@spec(Int) T](interval:Interval[T]) { val y = Some(interval) } + +class X2[T](val interval:Interval[T]) { val x = interval } +class Y2[T](val interval:Interval[T]) { val y = Some(interval) } + +class X3[@spec(Int) T](val interval:Interval[T]) { val x = interval } +class Y3[@spec(Int) T](val interval:Interval[T]) { val y = Some(interval) } + +object Test { + def tryit(o: => Any) = println(try { "ok: " + o.getClass.getName } catch { case e => "FAIL: " + e + "\n" + e.getStackTrace.mkString("\n ") }) + + def main(args: Array[String]) { + tryit(new X1(new Interval(3))) + tryit(new X2(new Interval(3))) + tryit(new X3(new Interval(3))) + tryit(new Y1(new Interval(3))) + tryit(new Y2(new Interval(3))) + tryit(new Y3(new Interval(3))) + } +} |