Skip to content

Commit a0ae794

Browse files
committed
WIP: use classDenot.findMember
1 parent 2991784 commit a0ae794

File tree

28 files changed

+165
-57
lines changed

28 files changed

+165
-57
lines changed

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,21 +1184,41 @@ class TreeUnpickler(reader: TastyReader,
11841184
case SELECTin =>
11851185
var sname = readName()
11861186
val qual = readTerm()
1187-
val owner = readType().typeSymbol
1187+
val ownerTpe = readType()
1188+
val owner = ownerTpe.typeSymbol
11881189
val SignedName(name, sig, target) = sname: @unchecked // only methods with params use SELECTin
11891190
val qualType = qual.tpe.widenIfUnstable
11901191
val prefix = ctx.typeAssigner.maybeSkolemizePrefix(qualType, name)
1191-
def matchOverload(denot: SingleDenotation) =
1192-
val sym = denot.symbol
1193-
sym.exists
1194-
&& sym.owner == owner
1195-
&& sym.targetName == target
1196-
&& sym.signature == sig
1197-
val denot = qualType.findMember(name, prefix).filterWithPredicate(matchOverload)
1198-
val select = makeSelect(qual, name, denot)
1199-
if !denot.exists && ctx.settings.YstrictTasty.value then
1192+
def overloadNotFound(select: Tree, symPart: String) =
12001193
typer.ErrorReporting.errorTree(select,
1201-
i"While unpickling, I was looking in (${qual.denot}: ${qual.tpe}) but could not find method $name (defined in ${owner.showLocated}, ${sname.info})")
1194+
i"""While unpickling, I was looking in `$qual` (of widened type: ${qual.tpe.widen})
1195+
|but could not find method `$name` (${sname.info}):
1196+
| - $symPart.""".stripMargin)
1197+
// def matchOverload(denot: SingleDenotation) =
1198+
// val sym = denot.symbol
1199+
// sym.exists
1200+
// && sym.owner == owner
1201+
// && sym.targetName == target
1202+
// && sym.signature == sig
1203+
// val denot = qualType.findMember(name, prefix).filterWithPredicate(matchOverload)
1204+
val denot =
1205+
// TODO: handle refinements
1206+
val cls = ownerTpe.classSymbol
1207+
if !cls.exists then NoDenotation
1208+
else
1209+
val clsDenot = cls.asClass.classDenot
1210+
val d0 = clsDenot.findMember(name, cls.thisType, EmptyFlags, EmptyFlags).atSignature(sig, target)
1211+
if !d0.symbol.exists || d0.symbol.isAccessibleFrom(prefix) then d0.asSeenFrom(prefix)
1212+
else
1213+
clsDenot.findMember(name, cls.thisType, EmptyFlags, excluded=Private)
1214+
.atSignature(sig, target)
1215+
.asSeenFrom(prefix)
1216+
val select = makeSelect(qual, name, denot)
1217+
if !(owner.exists && denot.exists) && ctx.settings.YstrictTasty.value then
1218+
val symPart =
1219+
if !owner.exists then i"its defining type ${ownerTpe} could not be found"
1220+
else i"defined in ${owner.showLocated}"
1221+
overloadNotFound(select, symPart)
12021222
else
12031223
select
12041224
case REPEATED =>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
lazy val a = project.in(file("a"))
2+
.settings(
3+
Compile / classDirectory := (ThisBuild / baseDirectory).value / "b-input"
4+
)
5+
6+
lazy val b = project.in(file("b"))
7+
.settings(
8+
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "b-input",
9+
Compile / classDirectory := (ThisBuild / baseDirectory).value / "c-input"
10+
)
11+
12+
lazy val `a-changes` = project.in(file("a-changes"))
13+
.settings(
14+
Compile / classDirectory := (ThisBuild / baseDirectory).value / "c-input"
15+
)
16+
17+
lazy val c = project.in(file("."))
18+
.settings(
19+
scalacOptions ++= Seq("-from-tasty", "-Ystrict-tasty", "-Ycheck:all"),
20+
Compile / sources := Seq(new java.io.File("c-input/B.tasty")),
21+
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "c-input",
22+
Compile / classDirectory := (ThisBuild / baseDirectory).value / "c-output"
23+
)
File renamed without changes.
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# compile library A
2+
> a/compile
3+
# compile library B, from source, against A
4+
> b/compile
5+
# add a refinement in library A', it changes the parameter names
6+
> a-changes/compile
7+
# compile B, from tasty, against A', it should continue compile: named arguments still ok.
8+
> c/compile

sbt-dotty/sbt-test/source-dependencies/tasty-add-refinement-incompat/test

Lines changed: 0 additions & 9 deletions
This file was deleted.

sbt-dotty/sbt-test/source-dependencies/tasty-add-refinement/a-changes/A.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)