Skip to content

Commit 4dc357e

Browse files
smarterDarkDimius
authored andcommitted
Fix scala#1009: Do not forget to skolemize some types
1 parent d063952 commit 4dc357e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class tests extends CompilerTest {
105105
@Test def pos_variancesConstr = compileFile(posSpecialDir, "variances-constr", scala2mode)
106106

107107
@Test def new_all = compileFiles(newDir, twice)
108-
/*
108+
109109
@Test def neg_abstractOverride() = compileFile(negDir, "abstract-override", xerrors = 2)
110110
@Test def neg_blockescapes() = compileFile(negDir, "blockescapesNeg", xerrors = 1)
111111
@Test def neg_bounds() = compileFile(negDir, "bounds", xerrors = 2)
@@ -172,7 +172,8 @@ class tests extends CompilerTest {
172172
@Test def neg_implicitLowerBound = compileFile(negDir, "implicit-lower-bound", xerrors = 1)
173173
@Test def neg_validate = compileFile(negDir, "validate", xerrors = 18)
174174
@Test def neg_validateParsing = compileFile(negDir, "validate-parsing", xerrors = 7)
175-
@Test def neg_validateRefchecks = compileFile(negDir, "validate-refchecks", xerrors = 2)*/
175+
@Test def neg_validateRefchecks = compileFile(negDir, "validate-refchecks", xerrors = 2)
176+
@Test def neg_skolemize = compileFile(negDir, "skolemize", xerrors = 2)
176177

177178
@Test def run_all = runFiles(runDir)
178179

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)