diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2016-05-23 16:20:01 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2016-05-23 16:20:01 +0200 |
commit | 82d9551773b56730df8cfcfc7a40a0d1c7fb2bf9 (patch) | |
tree | 700313eac714888a2e2d855031c76f1935bad980 | |
parent | 8e92ba0eb8c1e651c56493d00bc478ae7a3e9f39 (diff) | |
parent | 45e607d3879623d5163f47c17c717904f6867ef6 (diff) | |
download | scala-82d9551773b56730df8cfcfc7a40a0d1c7fb2bf9.tar.gz scala-82d9551773b56730df8cfcfc7a40a0d1c7fb2bf9.tar.bz2 scala-82d9551773b56730df8cfcfc7a40a0d1c7fb2bf9.zip |
Merge pull request #5162 from milessabin/t9361
SI-9361 fixed assert allowing display of improved error message.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t9361.check | 11 | ||||
-rw-r--r-- | test/files/neg/t9361.scala | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index e190b57017..90ccaefe43 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -198,7 +198,7 @@ trait ContextErrors { val foundType: Type = req.dealiasWiden match { case RefinedType(parents, decls) if !decls.isEmpty && found.typeSymbol.isAnonOrRefinementClass => val retyped = typed (tree.duplicate.clearType()) - val foundDecls = retyped.tpe.decls filter (sym => !sym.isConstructor && !sym.isSynthetic) + val foundDecls = retyped.tpe.decls filter (sym => !sym.isConstructor && !sym.isSynthetic && !sym.isErroneous) if (foundDecls.isEmpty || (found.typeSymbol eq NoSymbol)) found else { // The members arrive marked private, presumably because there was no @@ -212,7 +212,8 @@ trait ContextErrors { case _ => found } - assert(!foundType.isErroneous && !req.isErroneous, (foundType, req)) + assert(!foundType.isErroneous, s"AdaptTypeError - foundType is Erroneous: $foundType") + assert(!req.isErroneous, s"AdaptTypeError - req is Erroneous: $req") issueNormalTypeError(callee, withAddendum(callee.pos)(typeErrorMsg(foundType, req))) infer.explainTypes(foundType, req) diff --git a/test/files/neg/t9361.check b/test/files/neg/t9361.check new file mode 100644 index 0000000000..847d137f7d --- /dev/null +++ b/test/files/neg/t9361.check @@ -0,0 +1,11 @@ +t9361.scala:4: error: type mismatch; + found : Tc[_$2] where type _$2 + required: Nothing[] + new Foo { def tc = null.asInstanceOf[Tc[_]] } + ^ +t9361.scala:4: error: type mismatch; + found : Foo[Nothing] + required: Foo[Tc]{type T = Nothing} + new Foo { def tc = null.asInstanceOf[Tc[_]] } + ^ +two errors found diff --git a/test/files/neg/t9361.scala b/test/files/neg/t9361.scala new file mode 100644 index 0000000000..b689461e4d --- /dev/null +++ b/test/files/neg/t9361.scala @@ -0,0 +1,5 @@ +abstract class Foo[Tc[_]] { def tc: Tc[_] } +object Foo { + def foo[Tc[_]](): Foo[Tc] { type T = Nothing } = + new Foo { def tc = null.asInstanceOf[Tc[_]] } +} |