Skip to content

Commit 8e76e10

Browse files
committed
wip 8
1 parent 4808f47 commit 8e76e10

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,29 +1177,53 @@ class TreeUnpickler(reader: TastyReader,
11771177
val levels = readNat()
11781178
readTerm().outerSelect(levels, SkolemType(readType()))
11791179
case SELECTin =>
1180+
// ================================================================================
1181+
// Test Report
1182+
// ================================================================================
1183+
1184+
// 3 suites passed, 1 failed, 4 total
1185+
// tests/pos/avoid.scala failed
1186+
// tests/pos/i5418.scala failed
1187+
// tests/pos/i5980.scala failed
1188+
val srcnme = "???"
11801189
var symname = readName()
11811190
var precisesig = readName() match
11821191
case SignedName(_, sig, _) => sig
11831192
case _ => Signature.NotAMethod
11841193
val qual = readTerm()
11851194
val qualType = qual.tpe.widenIfUnstable
11861195
val space = if currentAddr == end then qualType else readType()
1187-
def selectAmbiguous(name: Name, pre: Type, denot: Denotation) =
1188-
makeSelect(qual, name, denot.asSeenFrom(pre))
11891196
def select(name: Name, sig: Signature, target: Name) =
1197+
def accessibleDenot(qualType: Type, name: Name, sig: Signature, target: Name) = {
1198+
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
1199+
val d1 = qualType.findMember(name, pre)
1200+
if !d1.isOverloaded && !d1.atSignature(sig, target).symbol.exists then
1201+
// TODO: workaround for refined types
1202+
d1
1203+
else
1204+
val d = space.decl(name).atSignature(sig, target)
1205+
if !d.symbol.exists then d
1206+
else if d.symbol.isAccessibleFrom(pre) then d.asSeenFrom(pre)
1207+
else space.nonPrivateDecl(name).atSignature(sig, target).asSeenFrom(pre)
1208+
}
11901209
makeSelect(qual, name, accessibleDenot(qualType, name, sig, target))
11911210
val res = symname match
11921211
case SignedName(name, sig, target) =>
11931212
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
11941213
assert(precisesig != Signature.NotAMethod)
11951214
val isAmbiguous = pre.nonPrivateMember(name).match
11961215
case d: MultiDenotation =>
1197-
d.atSignature(precisesig, target).isInstanceOf[MultiDenotation]
1216+
d.atSignature(sig, target).isInstanceOf[MultiDenotation]
11981217
case _ => false
11991218
if isAmbiguous then
1219+
if ctx.source.name.startsWith(srcnme) then
1220+
val diff = if sig != precisesig then i"$sig => $precisesig" else i"$sig"
1221+
report.error(i"$qual . $name differs ambiguously: [$diff]")
12001222
makeSelect(qual, name, space.decl(name).atSignature(sig, target).asSeenFrom(pre))
12011223
else
1202-
select(name, precisesig, target)
1224+
if ctx.source.name.startsWith(srcnme) && sig != precisesig then
1225+
report.error(i"$qual . $name differs: [$sig => $precisesig]")
1226+
select(name, sig, target)
12031227
case name =>
12041228
select(name, Signature.NotAMethod, EmptyTermName)
12051229
res

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ class FromTastyTests {
1313
import TestConfiguration._
1414
import FromTastyTests._
1515

16+
// @Test def postmpTestFromTasty: Unit = {
17+
// // Can be reproduced with
18+
// // > sbt
19+
// // > scalac -Ythrough-tasty -Ycheck:all <source>
20+
21+
// implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
22+
// compileTastyInDir(s"tests${JFile.separator}pos-tmp", defaultOptions,
23+
// fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted)
24+
// ).checkCompile()
25+
// }
26+
1627
@Test def posTestFromTasty: Unit = {
1728
// Can be reproduced with
1829
// > sbt

tests/pos-tmp/hashsetremove.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.collection.mutable.HashSet
2+
3+
4+
object Test extends App {
5+
val h = new HashSet[Int]
6+
h += 1
7+
assert(!h.remove(0))
8+
// assert(h(1))
9+
// assert(h.remove(1))
10+
// assert(!h(1))
11+
// assert(!h.remove(1))
12+
// assert(!h(1))
13+
}

tests/pos-tmp/i8516.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val x: Function1[Int, Int] { def apply(arg: Int): Int } = x => x
2+
val x1 = x
3+
val y = x.apply(arg = 1)

tests/pos-tmp/i9050.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
object Foo {
3+
val foo = scala.collection.mutable.ArrayBuffer.empty[Seq[Double]]
4+
val bar = Seq.empty[Double]
5+
foo.append(bar)
6+
foo.append(Seq(bar):_*)
7+
}

0 commit comments

Comments
 (0)