Skip to content

Commit 6368df2

Browse files
committed
wip 9
1 parent 8e76e10 commit 6368df2

File tree

4 files changed

+91
-5
lines changed

4 files changed

+91
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,10 +1182,11 @@ class TreeUnpickler(reader: TastyReader,
11821182
// ================================================================================
11831183

11841184
// 3 suites passed, 1 failed, 4 total
1185-
// tests/pos/avoid.scala failed
1185+
// ] failed
11861186
// tests/pos/i5418.scala failed
11871187
// tests/pos/i5980.scala failed
1188-
val srcnme = "???"
1188+
val srcnmes = Nil//List("i5980", "i5418")
1189+
val doinspect = srcnmes.exists(ctx.source.name.startsWith)
11891190
var symname = readName()
11901191
var precisesig = readName() match
11911192
case SignedName(_, sig, _) => sig
@@ -1216,16 +1217,19 @@ class TreeUnpickler(reader: TastyReader,
12161217
d.atSignature(sig, target).isInstanceOf[MultiDenotation]
12171218
case _ => false
12181219
if isAmbiguous then
1219-
if ctx.source.name.startsWith(srcnme) then
1220+
if doinspect then
12201221
val diff = if sig != precisesig then i"$sig => $precisesig" else i"$sig"
12211222
report.error(i"$qual . $name differs ambiguously: [$diff]")
12221223
makeSelect(qual, name, space.decl(name).atSignature(sig, target).asSeenFrom(pre))
12231224
else
1224-
if ctx.source.name.startsWith(srcnme) && sig != precisesig then
1225+
if doinspect && sig != precisesig then
12251226
report.error(i"$qual . $name differs: [$sig => $precisesig]")
12261227
select(name, sig, target)
12271228
case name =>
1228-
select(name, Signature.NotAMethod, EmptyTermName)
1229+
if doinspect then
1230+
report.error(i"$qual . $name nosig")
1231+
makeSelect(qual, name, accessibleDenot(qualType, name, Signature.NotAMethod, EmptyTermName))
1232+
// select(name, Signature.NotAMethod, EmptyTermName)
12291233
res
12301234
case REPEATED =>
12311235
val elemtpt = readTpt()

tests/pos-tmp/avoid.scala

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
abstract class C {
2+
def y: Any
3+
}
4+
5+
object test {
6+
val x = new C{
7+
def y: String = "abc"
8+
}
9+
val z: String = x.y
10+
}
11+
12+
trait M
13+
14+
// A tricky case involving inner classes, exercised
15+
// in the large in dotty.tools.dotc.core.NameKinds.scala.
16+
object Test2 {
17+
18+
class NK {
19+
class I
20+
type T
21+
}
22+
23+
val x = new NK { type T = I }
24+
25+
val y = {
26+
class C extends NK { type T = I }
27+
new C
28+
}
29+
30+
val z = {
31+
class C extends NK { type T = I }
32+
new C with M
33+
}
34+
}

tests/pos-tmp/i5418.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Test {
2+
class Tree[A]
3+
4+
def fromOrderedKeys[A](xs: Iterator[A]): Tree[A] = ???
5+
6+
def from[E](it: Iterable[E]): Tree[E] =
7+
it match {
8+
case r: Range =>
9+
val it = r.iterator
10+
11+
// instantiation of covariant GADTs is unsound
12+
fromOrderedKeys(it) // error: type mismatch: found: Iterator[Int](it), required Iterator[E]
13+
}
14+
}

tests/pos-tmp/i5980.scala

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
trait A
2+
trait B
3+
4+
trait Covariant[F[+_]] {
5+
trait G[+X]
6+
7+
def fx: F[A & B] = fy
8+
def fy: F[A] & F[B] = fx
9+
10+
def gx: G[A & B] = gy
11+
def gy: G[A] & G[B] = gx
12+
}
13+
14+
trait Contravariant[F[-_]] {
15+
trait G[-X]
16+
17+
def fx: F[A | B] = fy
18+
def fy: F[A] & F[B] = fx
19+
20+
def gx: G[A | B] = gy
21+
def gy: G[A] & G[B] = gx
22+
}
23+
24+
trait LiskovViolation[F[+_]] {
25+
trait A { def children: F[A] }
26+
trait B { def children: F[B] }
27+
trait C extends A with B { def children: F[A] & F[B] = ??? }
28+
29+
def fc1: C = new C {}
30+
def fc2: A & B = fc1
31+
32+
def fy1: F[A & B] = fc1.children
33+
def fy2: F[A & B] = fc2.children
34+
}

0 commit comments

Comments
 (0)