diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 22 | ||||
-rw-r--r-- | test/files/neg/any-vs-anyref.check | 18 | ||||
-rw-r--r-- | test/files/neg/applydynamic_sip.check | 17 | ||||
-rw-r--r-- | test/files/neg/macro-basic-mamdmi.check | 4 | ||||
-rw-r--r-- | test/files/neg/reflection-names-neg.check | 5 | ||||
-rw-r--r-- | test/files/neg/t512.check | 5 | ||||
-rw-r--r-- | test/files/neg/t5761.check | 5 | ||||
-rw-r--r-- | test/files/neg/t7895c.check | 13 | ||||
-rw-r--r-- | test/files/neg/t7895c.scala | 3 | ||||
-rw-r--r-- | test/files/run/constrained-types.check | 9 | ||||
-rw-r--r-- | test/files/run/repl-reset.check | 6 |
11 files changed, 94 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 0e4797d011..7bf342f475 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -81,14 +81,20 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } @inline final def orElse[T1 >: T](f: Seq[AbsTypeError] => T1): T1 = this match { case SilentResultValue(value) => value - case s : SilentTypeError => f(s.errors) + case s : SilentTypeError => f(s.reportableErrors) } } - class SilentTypeError private(val errors: Seq[AbsTypeError]) extends SilentResult[Nothing] { + class SilentTypeError private(val errors: List[AbsTypeError]) extends SilentResult[Nothing] { def err: AbsTypeError = errors.head + def reportableErrors = errors match { + case (e1: AmbiguousImplicitTypeError) +: _ => + List(e1) // DRYer error reporting for neg/t6436b.scala + case all => + all + } } object SilentTypeError { - def apply(errors: AbsTypeError*): SilentTypeError = new SilentTypeError(errors) + def apply(errors: AbsTypeError*): SilentTypeError = new SilentTypeError(errors.toList) def unapply(error: SilentTypeError): Option[AbsTypeError] = error.errors.headOption } @@ -2714,7 +2720,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val FunctionSymbol = FunctionClass(numVparams) val (argpts, respt) = pt baseType FunctionSymbol match { case TypeRef(_, FunctionSymbol, args :+ res) => (args, res) - case _ => (fun.vparams map (_ => NoType), WildcardType) + case _ => (fun.vparams map (_ => if (pt == ErrorType) ErrorType else NoType), WildcardType) } if (argpts.lengthCompare(numVparams) != 0) WrongNumberOfParametersError(fun, argpts) @@ -4278,8 +4284,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper tryTypedApply(fun2, args) else doTypedApply(tree, fun2, args, mode, pt) - case SilentTypeError(err) => - onError({ issue(err); setError(tree) }) + case err: SilentTypeError => + onError({ + err.reportableErrors foreach issue + args foreach (arg => typed(arg, mode, ErrorType)) + setError(tree) + }) } } diff --git a/test/files/neg/any-vs-anyref.check b/test/files/neg/any-vs-anyref.check index 63c4853130..7378f0495f 100644 --- a/test/files/neg/any-vs-anyref.check +++ b/test/files/neg/any-vs-anyref.check @@ -36,12 +36,28 @@ Such types can participate in value classes, but instances cannot appear in singleton types or in reference comparisons. def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x) ^ +any-vs-anyref.scala:10: error: type mismatch; + found : Quux with Product + required: AnyRef +Note that the parents of this type (Quux, Product) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x) + ^ any-vs-anyref.scala:11: error: value eq is not a member of Quux with Product{def f: Int} Note that the parents of this type (Quux, Product) extend Any, not AnyRef. Such types can participate in value classes, but instances cannot appear in singleton types or in reference comparisons. def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x) ^ +any-vs-anyref.scala:11: error: type mismatch; + found : Quux with Product{def f: Int} + required: AnyRef +Note that the parents of this type (Quux, Product) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x) + ^ any-vs-anyref.scala:12: error: type mismatch; found : Quux with Product{def eq(other: String): Boolean} required: AnyRef @@ -61,4 +77,4 @@ any-vs-anyref.scala:27: error: type mismatch; required: Quux{def g(x: Int): Int} f(new Quux { def g(x: String) = x }) ^ -9 errors found +11 errors found diff --git a/test/files/neg/applydynamic_sip.check b/test/files/neg/applydynamic_sip.check index dcf97b29fc..f28f26c147 100644 --- a/test/files/neg/applydynamic_sip.check +++ b/test/files/neg/applydynamic_sip.check @@ -4,9 +4,18 @@ applydynamic_sip.scala:7: error: applyDynamic does not support passing a vararg applydynamic_sip.scala:8: error: applyDynamicNamed does not support passing a vararg parameter qual.sel(arg = a, a2: _*) ^ +applydynamic_sip.scala:8: error: not found: value arg + qual.sel(arg = a, a2: _*) + ^ applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter qual.sel(arg, arg2 = "a2", a2: _*) ^ +applydynamic_sip.scala:9: error: not found: value arg + qual.sel(arg, arg2 = "a2", a2: _*) + ^ +applydynamic_sip.scala:9: error: not found: value arg2 + qual.sel(arg, arg2 = "a2", a2: _*) + ^ applydynamic_sip.scala:18: error: type mismatch; found : String("sel") required: Int @@ -28,6 +37,9 @@ error after rewriting to Test.this.bad1.applyDynamicNamed("sel") possible cause: maybe a wrong Dynamic method signature? bad1.sel(a = 1) ^ +applydynamic_sip.scala:20: error: reassignment to val + bad1.sel(a = 1) + ^ applydynamic_sip.scala:21: error: type mismatch; found : String("sel") required: Int @@ -50,9 +62,12 @@ error after rewriting to Test.this.bad2.applyDynamicNamed("sel") possible cause: maybe a wrong Dynamic method signature? bad2.sel(a = 1) ^ +applydynamic_sip.scala:31: error: reassignment to val + bad2.sel(a = 1) + ^ applydynamic_sip.scala:32: error: Int does not take parameters error after rewriting to Test.this.bad2.updateDynamic("sel") possible cause: maybe a wrong Dynamic method signature? bad2.sel = 1 ^ -11 errors found +16 errors found diff --git a/test/files/neg/macro-basic-mamdmi.check b/test/files/neg/macro-basic-mamdmi.check index 621d318ceb..9328fbd51c 100644 --- a/test/files/neg/macro-basic-mamdmi.check +++ b/test/files/neg/macro-basic-mamdmi.check @@ -1,5 +1,5 @@ -Impls_Macros_Test_1.scala:36: error: macro implementation not found: foo +Impls_Macros_Test_1.scala:36: error: macro implementation not found: quux (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) println(foo(2) + Macros.bar(2) * new Macros().quux(4)) - ^ + ^ one error found diff --git a/test/files/neg/reflection-names-neg.check b/test/files/neg/reflection-names-neg.check index a56a19e7fd..f941ec8dc1 100644 --- a/test/files/neg/reflection-names-neg.check +++ b/test/files/neg/reflection-names-neg.check @@ -7,4 +7,7 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from String("abc") to reflect.runtime.universe.Name val x2 = ("abc": Name) drop 1 // error ^ -one error found +reflection-names-neg.scala:5: error: value drop is not a member of reflect.runtime.universe.Name + val x2 = ("abc": Name) drop 1 // error + ^ +two errors found diff --git a/test/files/neg/t512.check b/test/files/neg/t512.check index 814e65e405..051e5ee19f 100644 --- a/test/files/neg/t512.check +++ b/test/files/neg/t512.check @@ -1,4 +1,7 @@ t512.scala:3: error: not found: value something val xxx = something || ^ -one error found +t512.scala:4: error: not found: value something_else + something_else; + ^ +two errors found diff --git a/test/files/neg/t5761.check b/test/files/neg/t5761.check index 89d766fe34..2d66af26f6 100644 --- a/test/files/neg/t5761.check +++ b/test/files/neg/t5761.check @@ -13,4 +13,7 @@ Unspecified value parameter x. t5761.scala:13: error: not found: type Tread new Tread("sth") { }.run() ^ -four errors found +t5761.scala:13: error: value run is not a member of AnyRef + new Tread("sth") { }.run() + ^ +5 errors found diff --git a/test/files/neg/t7895c.check b/test/files/neg/t7895c.check new file mode 100644 index 0000000000..d4745b1f4b --- /dev/null +++ b/test/files/neg/t7895c.check @@ -0,0 +1,13 @@ +t7895c.scala:2: error: not found: value bong + def booboo = bong + booble + bippity - bazingo + ^ +t7895c.scala:2: error: not found: value booble + def booboo = bong + booble + bippity - bazingo + ^ +t7895c.scala:2: error: not found: value bippity + def booboo = bong + booble + bippity - bazingo + ^ +t7895c.scala:2: error: not found: value bazingo + def booboo = bong + booble + bippity - bazingo + ^ +four errors found diff --git a/test/files/neg/t7895c.scala b/test/files/neg/t7895c.scala new file mode 100644 index 0000000000..53d2a8672e --- /dev/null +++ b/test/files/neg/t7895c.scala @@ -0,0 +1,3 @@ +class A { + def booboo = bong + booble + bippity - bazingo +} diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index f022aac1b2..d965d8a2ff 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -138,6 +138,15 @@ scala> val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message <console>:8: error: not found: value e val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message ^ +<console>:8: error: not found: value f + val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message + ^ +<console>:8: error: not found: value g + val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message + ^ +<console>:8: error: not found: value h + val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message + ^ scala> diff --git a/test/files/run/repl-reset.check b/test/files/run/repl-reset.check index c6e147977a..ed95c7b8ff 100644 --- a/test/files/run/repl-reset.check +++ b/test/files/run/repl-reset.check @@ -33,6 +33,12 @@ scala> x1 + x2 + x3 <console>:8: error: not found: value x1 x1 + x2 + x3 ^ +<console>:8: error: not found: value x2 + x1 + x2 + x3 + ^ +<console>:8: error: not found: value x3 + x1 + x2 + x3 + ^ scala> val x1 = 4 x1: Int = 4 |