forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix scala#14432: check if scala 2 case class is accessible
- Loading branch information
1 parent
b636633
commit 8699a84
Showing
8 changed files
with
90 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import deriving.Mirror | ||
|
||
val mFoo = summon[Mirror.Of[Foo]] // error: `Foo.<init>(Int)` is not accessible from `<empty>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import deriving.Mirror | ||
|
||
package example { | ||
val mFoo = summon[Mirror.Of[Foo]] // ok, we can access Foo's ctor from here. | ||
} | ||
|
||
@main def Test: Unit = | ||
assert(example.mFoo.fromProduct(Some(23)) == example.Foo(23)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package example | ||
|
||
import deriving.Mirror | ||
|
||
val mFoo = summon[Mirror.Of[Foo]] // error: `Foo.<init>(Int)` is not accessible from any class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
val scala3Version = sys.props("plugin.scalaVersion") | ||
val scala2Version = sys.props("plugin.scala2Version") | ||
|
||
lazy val lib1 = project.in(file("lib1")) | ||
.settings( | ||
scalaVersion := scala2Version | ||
) | ||
|
||
lazy val lib2 = project.in(file("lib2")) | ||
.settings( | ||
scalaVersion := scala2Version | ||
) | ||
|
||
lazy val app1fail = project.in(file("app1fail")) | ||
.dependsOn(lib1) | ||
.settings( | ||
scalaVersion := scala3Version | ||
) | ||
|
||
lazy val app1ok = project.in(file("app1ok")) | ||
.dependsOn(lib1) | ||
.settings( | ||
scalaVersion := scala3Version | ||
) | ||
|
||
lazy val app2fail = project.in(file("app2fail")) | ||
.dependsOn(lib2) | ||
.settings( | ||
scalaVersion := scala3Version | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package example | ||
|
||
case class Foo private[example] (i: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package example | ||
|
||
case class Foo private (i: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
> lib1/compile | ||
> lib2/compile | ||
-> app1fail/compile | ||
> app1ok/run | ||
-> app2fail/compile |