Skip to content

Commit c2cf243

Browse files
committed
wip 8
1 parent d5f699a commit c2cf243

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
@@ -1179,29 +1179,53 @@ class TreeUnpickler(reader: TastyReader,
11791179
val levels = readNat()
11801180
readTerm().outerSelect(levels, SkolemType(readType()))
11811181
case SELECTin =>
1182+
// ================================================================================
1183+
// Test Report
1184+
// ================================================================================
1185+
1186+
// 3 suites passed, 1 failed, 4 total
1187+
// tests/pos/avoid.scala failed
1188+
// tests/pos/i5418.scala failed
1189+
// tests/pos/i5980.scala failed
1190+
val srcnme = "???"
11821191
var symname = readName()
11831192
var precisesig = readName() match
11841193
case SignedName(_, sig, _) => sig
11851194
case _ => Signature.NotAMethod
11861195
val qual = readTerm()
11871196
val qualType = qual.tpe.widenIfUnstable
11881197
val space = if currentAddr == end then qualType else readType()
1189-
def selectAmbiguous(name: Name, pre: Type, denot: Denotation) =
1190-
makeSelect(qual, name, denot.asSeenFrom(pre))
11911198
def select(name: Name, sig: Signature, target: Name) =
1199+
def accessibleDenot(qualType: Type, name: Name, sig: Signature, target: Name) = {
1200+
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
1201+
val d1 = qualType.findMember(name, pre)
1202+
if !d1.isOverloaded && !d1.atSignature(sig, target).symbol.exists then
1203+
// TODO: workaround for refined types
1204+
d1
1205+
else
1206+
val d = space.decl(name).atSignature(sig, target)
1207+
if !d.symbol.exists then d
1208+
else if d.symbol.isAccessibleFrom(pre) then d.asSeenFrom(pre)
1209+
else space.nonPrivateDecl(name).atSignature(sig, target).asSeenFrom(pre)
1210+
}
11921211
makeSelect(qual, name, accessibleDenot(qualType, name, sig, target))
11931212
val res = symname match
11941213
case SignedName(name, sig, target) =>
11951214
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
11961215
assert(precisesig != Signature.NotAMethod)
11971216
val isAmbiguous = pre.nonPrivateMember(name).match
11981217
case d: MultiDenotation =>
1199-
d.atSignature(precisesig, target).isInstanceOf[MultiDenotation]
1218+
d.atSignature(sig, target).isInstanceOf[MultiDenotation]
12001219
case _ => false
12011220
if isAmbiguous then
1221+
if ctx.source.name.startsWith(srcnme) then
1222+
val diff = if sig != precisesig then i"$sig => $precisesig" else i"$sig"
1223+
report.error(i"$qual . $name differs ambiguously: [$diff]")
12021224
makeSelect(qual, name, space.decl(name).atSignature(sig, target).asSeenFrom(pre))
12031225
else
1204-
select(name, precisesig, target)
1226+
if ctx.source.name.startsWith(srcnme) && sig != precisesig then
1227+
report.error(i"$qual . $name differs: [$sig => $precisesig]")
1228+
select(name, sig, target)
12051229
case name =>
12061230
select(name, Signature.NotAMethod, EmptyTermName)
12071231
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)