Skip to content

Commit 5102e08

Browse files
committed
test elided trees with method and static final field results
1 parent 32d4c62 commit 5102e08

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package a;
2+
3+
public class A {
4+
public static final String VALUE = "A";
5+
6+
public <T> String add(T t) {
7+
return VALUE + t.toString();
8+
}
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// THIS FILE EXISTS SO THAT `A.java` WILL BE COMPILED BY SCALAC
2+
package a
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package b
2+
3+
import a.A
4+
5+
object B {
6+
val finalResult: "A" = A.VALUE
7+
8+
val a_B: String = (new A()).add("B")
9+
val a_true: String = (new A()).add(true)
10+
11+
@main def test = {
12+
assert(finalResult == "A")
13+
assert(a_B == "AB")
14+
assert(a_true == "Atrue")
15+
}
16+
}
17+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
lazy val a = project.in(file("a"))
2+
.settings(
3+
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
4+
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar").toString),
5+
scalacOptions += "-Ycheck:all",
6+
classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory
7+
)
8+
9+
lazy val b = project.in(file("b"))
10+
.settings(
11+
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar")),
12+
scalacOptions += "-Ycheck:all",
13+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
scalacOptions += "-source:3.0-migration"
11+
)
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
> a/compile
2+
# Test depending on a java static final result, and method result through TASTy
3+
> b/compile

0 commit comments

Comments
 (0)