diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2015-12-23 23:28:59 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2015-12-24 19:05:20 +0100 |
commit | 8d8fd269a5e798d4951041c2851ee3b7bd33185d (patch) | |
tree | 534280e64d7583bff7c36b5cbdfc25cbee88c49a | |
parent | c66613de7f32cfabbca765a96f1a3cc0ea2d5bcb (diff) | |
download | dotty-8d8fd269a5e798d4951041c2851ee3b7bd33185d.tar.gz dotty-8d8fd269a5e798d4951041c2851ee3b7bd33185d.tar.bz2 dotty-8d8fd269a5e798d4951041c2851ee3b7bd33185d.zip |
Fix #1009: Do not forget to skolemize some types
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 2 | ||||
-rw-r--r-- | test/dotc/tests.scala | 1 | ||||
-rw-r--r-- | tests/neg/skolemize.scala | 13 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 9232bd185..04cd2249d 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -102,7 +102,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object. asSeenFrom(tp.parent, pre, cls, theMap), tp.refinedName, asSeenFrom(tp.refinedInfo, pre, cls, theMap)) - case tp: TypeAlias if theMap == null => // if theMap exists, need to do the variance calculation + case tp: TypeAlias if tp.variance == 1 => // if variance != 1, need to do the variance calculation tp.derivedTypeAlias(asSeenFrom(tp.alias, pre, cls, theMap)) case _ => (if (theMap != null) theMap else new AsSeenFromMap(pre, cls)) diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index db5fa8544..d702b7b00 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -172,6 +172,7 @@ class tests extends CompilerTest { @Test def neg_validate = compileFile(negDir, "validate", xerrors = 18) @Test def neg_validateParsing = compileFile(negDir, "validate-parsing", xerrors = 7) @Test def neg_validateRefchecks = compileFile(negDir, "validate-refchecks", xerrors = 2) + @Test def neg_skolemize = compileFile(negDir, "skolemize", xerrors = 2) @Test def run_all = runFiles(runDir) diff --git a/tests/neg/skolemize.scala b/tests/neg/skolemize.scala new file mode 100644 index 000000000..77045cfc4 --- /dev/null +++ b/tests/neg/skolemize.scala @@ -0,0 +1,13 @@ +class Inv[T] + +class Foo { + val foo: Inv[this.type] = new Inv[this.type] +} +object Test { + def test: Unit = { + val e1 = new Foo + val f1: Inv[Foo] = e1.foo // error + var e2 = new Foo + val f2: Inv[Foo] = e2.foo // error + } +} |