Skip to content

Commit 41f8542

Browse files
committed
wip 2
1 parent 7f8b7b5 commit 41f8542

File tree

5 files changed

+46
-43
lines changed

5 files changed

+46
-43
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ class TreePickler(pickler: TastyPickler) {
425425
pickleTree(qual)
426426
if tree.symbol.exists then
427427
pickleType(tree.symbol.owner.typeRef)
428-
// else
429-
// pickleType(defn.NothingType)
430428
}
431429
}
432430
case Apply(fun, args) =>

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,6 @@ class TreeUnpickler(reader: TastyReader,
10631063
case name: TypeName => TypeRef(qualType, name, denot)
10641064
case name: TermName => TermRef(qualType, name, denot)
10651065
}
1066-
if ctx.source.name.startsWith("i") && name.isTermName then
1067-
report.echo(i"""complete select $qual.$name as $tpe""")
10681066
ConstFold.Select(untpd.Select(qual, name).withType(tpe))
10691067

10701068
def completeSelect(name: Name, sig: Signature, target: Name): Select =
@@ -1197,21 +1195,23 @@ class TreeUnpickler(reader: TastyReader,
11971195
var sname = readName()
11981196
val qual = readTerm()
11991197
val qualType = qual.tpe.widenIfUnstable
1200-
val space = if currentAddr == end then ??? else readType()
1201-
def select(name: Name, denot: Denotation) =
1202-
val prefix = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
1203-
makeSelect(qual, name, denot.asSeenFrom(prefix))
1198+
val space = if currentAddr == end then qualType else readType()
1199+
def selectAmbiguous(name: Name, pre: Type, denot: Denotation) =
1200+
makeSelect(qual, name, denot.asSeenFrom(pre))
1201+
def select(name: Name, sig: Signature, target: Name) =
1202+
makeSelect(qual, name, accessibleDenot(qualType, name, sig, target))
12041203
sname match
12051204
case SignedName(name, sig, target) =>
1206-
// val isAmbiguous = qualType.nonPrivateMember(name) match
1207-
// case d: MultiDenotation => d.atSignature(sig, target).isInstanceOf[MultiDenotation]
1208-
// case _ => false
1209-
// if isAmbiguous then
1210-
// select(name, space.decl(name).atSignature(sig, target))
1211-
// else
1212-
completeSelect(name, sig, target)
1205+
val pre = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
1206+
val isAmbiguous = pre.nonPrivateMember(name).isOverloaded
1207+
if ctx.source.name.startsWith("i9050") then
1208+
report.echo(i"select $name at $sig isAmbig? $isAmbiguous")
1209+
if isAmbiguous then
1210+
selectAmbiguous(name, pre, space.decl(name).atSignature(sig, target))
1211+
else
1212+
select(name, sig, target)
12131213
case name =>
1214-
completeSelect(name, Signature.NotAMethod, EmptyTermName)
1214+
select(name, Signature.NotAMethod, EmptyTermName)
12151215
case REPEATED =>
12161216
val elemtpt = readTpt()
12171217
SeqLiteral(until(end)(readTerm()), elemtpt)

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
169169

170170
protected def handleRuntimeException(ex: RuntimeException)(using Context): Nothing = ex match {
171171
case ex: BadSignature => throw ex
172-
case _ => errorBadSignature(s"a runtime exception occurred: $ex", Some(ex))
172+
case _ => errorBadSignature(s"a runtime exception occurred: $ex at ${ex.getStackTrace.mkString("\n")}", Some(ex))
173173
}
174174

175175
def run()(using Context): Unit =

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ 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("posTmpTestFromTasty")
22-
compileTastyInDir(s"tests${JFile.separator}pos-tmp", defaultOptions,
23-
fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted)
24-
).checkCompile()
25-
}
26-
27-
// @Test def posTestFromTasty: Unit = {
16+
// @Test def posTmpTestFromTasty: Unit = {
2817
// // Can be reproduced with
2918
// // > sbt
3019
// // > scalac -Ythrough-tasty -Ycheck:all <source>
3120

32-
// implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
33-
// compileTastyInDir(s"tests${JFile.separator}pos", defaultOptions,
21+
// implicit val testGroup: TestGroup = TestGroup("posTmpTestFromTasty")
22+
// compileTastyInDir(s"tests${JFile.separator}pos-tmp", defaultOptions,
3423
// fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted)
3524
// ).checkCompile()
3625
// }
3726

38-
// @Test def runTestFromTasty: Unit = {
39-
// // Can be reproduced with
40-
// // > sbt
41-
// // > scalac -Ythrough-tasty -Ycheck:all <source>
42-
// // > scala Test
27+
@Test def posTestFromTasty: Unit = {
28+
// Can be reproduced with
29+
// > sbt
30+
// > scalac -Ythrough-tasty -Ycheck:all <source>
4331

44-
// implicit val testGroup: TestGroup = TestGroup("runTestFromTasty")
45-
// compileTastyInDir(s"tests${JFile.separator}run", defaultOptions,
46-
// fromTastyFilter = FileFilter.exclude(TestSources.runFromTastyBlacklisted)
47-
// ).checkRuns()
48-
// }
32+
implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
33+
compileTastyInDir(s"tests${JFile.separator}pos", defaultOptions,
34+
fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted)
35+
).checkCompile()
36+
}
37+
38+
@Test def runTestFromTasty: Unit = {
39+
// Can be reproduced with
40+
// > sbt
41+
// > scalac -Ythrough-tasty -Ycheck:all <source>
42+
// > scala Test
43+
44+
implicit val testGroup: TestGroup = TestGroup("runTestFromTasty")
45+
compileTastyInDir(s"tests${JFile.separator}run", defaultOptions,
46+
fromTastyFilter = FileFilter.exclude(TestSources.runFromTastyBlacklisted)
47+
).checkRuns()
48+
}
4949
}
5050

5151
object FromTastyTests extends ParallelTesting {

tests/pos-tmp/i8516.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
val x: Function1[Int, Int] { def apply(arg: Int): Int } = x => x
1+
abstract class Fn1[-A, +B] {
2+
def apply(v1: A, x: Int): B
3+
}
4+
val x: Fn1[Int, Int] { def apply(arg: Int, i: Int): Int } = new Fn1[Int, Int] {
5+
def apply(arg: Int, i: Int): Int = arg
6+
}
27
val x1 = x
3-
val y = x.apply(arg = 1)
8+
val y = x.apply(arg = 1, i = 2)

0 commit comments

Comments
 (0)