Skip to content

Commit 827b978

Browse files
committed
Test for contravariantly used class fields
As discussed in the CC meeting on 21 Jan 2022
1 parent b829c69 commit 827b978

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class TreePickler(pickler: TastyPickler) {
208208
writeByte(if (tpe.isType) TYPEREFdirect else TERMREFdirect)
209209
if Config.checkLevels && !symRefs.contains(sym) && !sym.isPatternBound && !sym.hasAnnotation(defn.QuotedRuntimePatterns_patternTypeAnnot) then
210210
report.error(i"pickling reference to as yet undefined $tpe with symbol ${sym}", sym.srcPos)
211+
// todo: find out why this happens for pos-customargs/captures/capt2
211212
pickleSymRef(sym)
212213
}
213214
else tpe.designator match {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-contra.scala:12:39 ---------------------------------
2+
12 | def fun(x: K{val f: {a} T}) = x.setf(a) // error
3+
| ^
4+
| Found: (a : {x, y} T)
5+
| Required: T
6+
7+
longer explanation available when compiling with `-explain`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
class C
3+
type Cap = {*} C
4+
5+
class K(val f: {*} T):
6+
def setf(x: {f} T) = ???
7+
8+
class T
9+
10+
def test(x: Cap, y: Cap) =
11+
val a: {x, y} T = ???
12+
def fun(x: K{val f: {a} T}) = x.setf(a) // error
13+
()

0 commit comments

Comments
 (0)