diff options
author | Martin Odersky <odersky@gmail.com> | 2015-11-05 14:13:14 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-11-05 14:13:40 +0100 |
commit | 1e280d03886e3b20fa28661b0d25b6b11dec56f3 (patch) | |
tree | 1b0dcad7124c0e7cb9881f0c629fb01195fb5a48 /test/dotc/tests.scala | |
parent | 4b76eeaa13176aede421af3fe86c392c438b0e5d (diff) | |
download | dotty-1e280d03886e3b20fa28661b0d25b6b11dec56f3.tar.gz dotty-1e280d03886e3b20fa28661b0d25b6b11dec56f3.tar.bz2 dotty-1e280d03886e3b20fa28661b0d25b6b11dec56f3.zip |
Handle variance unsoundness in scalac
The included test
pos-special/variances-constr.scala
demonstrates an unsoundness in the variance checking of scalac.
Scalac excludes symbols owned by constructors from the
checking. This is unsound, as can be demonstrated by compiling the test
and observing output of the program run:
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at Test$.main(variances-constr.scala:17)
at Test.main(variances-constr.scala)
Dotty allows this code only under -language:Scala2 and issues a migration warning.
Diffstat (limited to 'test/dotc/tests.scala')
-rw-r--r-- | test/dotc/tests.scala | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 596c4a27e..e37a53084 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -102,6 +102,7 @@ class tests extends CompilerTest { @Test def pos_t2613 = compileFile(posSpecialDir, "t2613")(allowDeepSubtypes) @Test def pos_i871 = compileFile(posSpecialDir, "i871", scala2mode) + @Test def pos_variancesConstr = compileFile(posSpecialDir, "variances-constr", scala2mode) @Test def new_all = compileFiles(newDir, twice) @@ -137,6 +138,7 @@ class tests extends CompilerTest { @Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 2) @Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 5) @Test def neg_variances = compileFile(negDir, "variances", xerrors = 2) + @Test def neg_variancesConstr = compileFile(negDir, "variances-constr", xerrors = 2) @Test def neg_i871_missingReturnType = compileFile(negDir, "i871", xerrors = 2) @Test def neg_badAuxConstr = compileFile(negDir, "badAuxConstr", xerrors = 2) @Test def neg_typetest = compileFile(negDir, "typetest", xerrors = 1) |