Skip to content

Commit 97c6969

Browse files
committed
add test for new location of method in tasty
1 parent 013e08a commit 97c6969

File tree

10 files changed

+85
-7
lines changed

10 files changed

+85
-7
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,9 @@ class TreeUnpickler(reader: TastyReader,
11941194
&& sym.owner == owner
11951195
&& sym.targetName == target
11961196
&& sym.signature == sig
1197-
makeSelect(qual, name, qualType.findMember(name, prefix).filterWithPredicate(matchOverload))
1197+
val denot = qualType.findMember(name, prefix).filterWithPredicate(matchOverload)
1198+
// TODO: if denot == NoDenotation then ???
1199+
makeSelect(qual, name, denot)
11981200
case REPEATED =>
11991201
val elemtpt = readTpt()
12001202
SeqLiteral(until(end)(readTerm()), elemtpt)

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,13 @@ trait MessageRendering {
149149
if (posString.nonEmpty) sb.append(posString).append(EOL)
150150
if (pos.exists) {
151151
val pos1 = pos.nonInlined
152-
val (srcBefore, srcAfter, offset) = sourceLines(pos1, diagnosticLevel)
153-
val marker = columnMarker(pos1, offset, diagnosticLevel)
154-
val err = errorMsg(pos1, msg.message, offset)
155-
sb.append((srcBefore ::: marker :: err :: outer(pos, " " * (offset - 1)) ::: srcAfter).mkString(EOL))
152+
if (pos1.exists && pos1.source.file.exists) {
153+
val (srcBefore, srcAfter, offset) = sourceLines(pos1, diagnosticLevel)
154+
val marker = columnMarker(pos1, offset, diagnosticLevel)
155+
val err = errorMsg(pos1, msg.message, offset)
156+
sb.append((srcBefore ::: marker :: err :: outer(pos, " " * (offset - 1)) ::: srcAfter).mkString(EOL))
157+
}
158+
else sb.append(msg.message)
156159
}
157160
else sb.append(msg.message)
158161
sb.toString

compiler/src/dotty/tools/dotc/util/SourceFile.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
196196
var idx = startOfLine(offset)
197197
var col = 0
198198
while (idx != offset) {
199-
col += (if (idx < length && content()(idx) == '\t') (tabInc - col) % tabInc else 1)
199+
col += (if (idx < length && idx < content().length && content()(idx) == '\t') (tabInc - col) % tabInc else 1)
200200
idx += 1
201201
}
202202
col
@@ -285,4 +285,3 @@ object SourceFile {
285285
override def exists: Boolean = false
286286
override def atSpan(span: Span): SourcePosition = NoSourcePosition
287287
}
288-
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package a
2+
3+
object A {
4+
5+
trait Box0[A] {
6+
def append(a: A): this.type = this
7+
def append(a: String): Unit = ()
8+
}
9+
10+
trait BoxInt extends Box0[Int] {
11+
override def append(a: Int): this.type = this
12+
}
13+
14+
val box: BoxInt = new BoxInt {}
15+
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package a
2+
3+
object A {
4+
5+
trait Box0[A] {
6+
def append(a: A): this.type = this
7+
def append(a: String): Unit = ()
8+
}
9+
10+
trait BoxInt extends Box0[Int]
11+
12+
val box: BoxInt = new BoxInt {}
13+
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import a.*
2+
3+
object B extends App {
4+
A.box.append(0)
5+
}
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("c"))
18+
.settings(
19+
scalacOptions ++= Seq("-from-tasty"),
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+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sbt._
2+
import Keys._
3+
4+
object DottyInjectedPlugin extends AutoPlugin {
5+
override def requires = plugins.JvmPlugin
6+
override def trigger = allRequirements
7+
8+
override val projectSettings = Seq(
9+
scalaVersion := sys.props("plugin.scalaVersion")
10+
)
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version"))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> a/compile
2+
> b/compile
3+
> a-changes/compile
4+
> c/compile

0 commit comments

Comments
 (0)