Skip to content

Commit

Permalink
Fix scala#1009: Do not forget to skolemize some types
Browse files Browse the repository at this point in the history
  • Loading branch information
smarter committed Dec 24, 2015
1 parent c66613d commit 8d8fd26
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions tests/neg/skolemize.scala
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 8d8fd26

Please sign in to comment.