Skip to content

Commit 54bdb67

Browse files
committed
wip 9
1 parent c2cf243 commit 54bdb67

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
@@ -1184,10 +1184,11 @@ class TreeUnpickler(reader: TastyReader,
11841184
// ================================================================================
11851185

11861186
// 3 suites passed, 1 failed, 4 total
1187-
// tests/pos/avoid.scala failed
1187+
// ] failed
11881188
// tests/pos/i5418.scala failed
11891189
// tests/pos/i5980.scala failed
1190-
val srcnme = "???"
1190+
val srcnmes = Nil//List("i5980", "i5418")
1191+
val doinspect = srcnmes.exists(ctx.source.name.startsWith)
11911192
var symname = readName()
11921193
var precisesig = readName() match
11931194
case SignedName(_, sig, _) => sig
@@ -1218,16 +1219,19 @@ class TreeUnpickler(reader: TastyReader,
12181219
d.atSignature(sig, target).isInstanceOf[MultiDenotation]
12191220
case _ => false
12201221
if isAmbiguous then
1221-
if ctx.source.name.startsWith(srcnme) then
1222+
if doinspect then
12221223
val diff = if sig != precisesig then i"$sig => $precisesig" else i"$sig"
12231224
report.error(i"$qual . $name differs ambiguously: [$diff]")
12241225
makeSelect(qual, name, space.decl(name).atSignature(sig, target).asSeenFrom(pre))
12251226
else
1226-
if ctx.source.name.startsWith(srcnme) && sig != precisesig then
1227+
if doinspect && sig != precisesig then
12271228
report.error(i"$qual . $name differs: [$sig => $precisesig]")
12281229
select(name, sig, target)
12291230
case name =>
1230-
select(name, Signature.NotAMethod, EmptyTermName)
1231+
if doinspect then
1232+
report.error(i"$qual . $name nosig")
1233+
makeSelect(qual, name, accessibleDenot(qualType, name, Signature.NotAMethod, EmptyTermName))
1234+
// select(name, Signature.NotAMethod, EmptyTermName)
12311235
res
12321236
case REPEATED =>
12331237
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)