Skip to content

Commit be3ab3f

Browse files
committed
Merge pull request #1010 from dotty-staging/fix/new-asSeenFrom
Fix #1009: Do not forget to skolemize some types
2 parents 2427f05 + 8d8fd26 commit be3ab3f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
102102
asSeenFrom(tp.parent, pre, cls, theMap),
103103
tp.refinedName,
104104
asSeenFrom(tp.refinedInfo, pre, cls, theMap))
105-
case tp: TypeAlias if theMap == null => // if theMap exists, need to do the variance calculation
105+
case tp: TypeAlias if tp.variance == 1 => // if variance != 1, need to do the variance calculation
106106
tp.derivedTypeAlias(asSeenFrom(tp.alias, pre, cls, theMap))
107107
case _ =>
108108
(if (theMap != null) theMap else new AsSeenFromMap(pre, cls))

test/dotc/tests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class tests extends CompilerTest {
172172
@Test def neg_validate = compileFile(negDir, "validate", xerrors = 18)
173173
@Test def neg_validateParsing = compileFile(negDir, "validate-parsing", xerrors = 7)
174174
@Test def neg_validateRefchecks = compileFile(negDir, "validate-refchecks", xerrors = 2)
175+
@Test def neg_skolemize = compileFile(negDir, "skolemize", xerrors = 2)
175176

176177
@Test def run_all = runFiles(runDir)
177178

tests/neg/skolemize.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Inv[T]
2+
3+
class Foo {
4+
val foo: Inv[this.type] = new Inv[this.type]
5+
}
6+
object Test {
7+
def test: Unit = {
8+
val e1 = new Foo
9+
val f1: Inv[Foo] = e1.foo // error
10+
var e2 = new Foo
11+
val f2: Inv[Foo] = e2.foo // error
12+
}
13+
}

0 commit comments

Comments
 (0)