-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10765 from dotty-staging/poly-vc-new-3
Fix #8001: Erase polymorphic value classes like Scala 2
- Loading branch information
Showing
24 changed files
with
256 additions
and
92 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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
val scala3Version = sys.props("plugin.scalaVersion") | ||
val scala2Version = "2.13.4" | ||
|
||
lazy val lib = (project in file ("lib")) | ||
.settings(scalaVersion := scala2Version) | ||
|
||
lazy val test = (project in file ("main")) | ||
.dependsOn(lib) | ||
.settings( | ||
scalaVersion := scala3Version, | ||
// https://github.com/sbt/sbt/issues/5369 | ||
projectDependencies := { | ||
projectDependencies.value.map(_.withDottyCompat(scalaVersion.value)) | ||
} | ||
) |
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,43 @@ | ||
class Poly[A](val value: A) extends AnyVal | ||
|
||
class Arr[A](val value: Array[A]) extends AnyVal | ||
|
||
class ArrRef[A <: AnyRef](val value: Array[A]) extends AnyVal | ||
|
||
class A { | ||
def poly1(x: Poly[Int]): Poly[Int] = | ||
new Poly(x.value) | ||
|
||
def poly2(x: Poly[String]): Poly[String] = | ||
new Poly(x.value) | ||
|
||
def poly3(x: Poly[Array[Int]]): Poly[Array[Int]] = | ||
new Poly(x.value) | ||
|
||
def poly4(x: Poly[Array[String]]): Poly[Array[String]] = | ||
new Poly(x.value) | ||
|
||
def arr1(x: Arr[Int]): Arr[Int] = | ||
new Arr(x.value) | ||
|
||
def arr2(x: Arr[String]): Arr[String] = | ||
new Arr(x.value) | ||
|
||
def arr3(x: Arr[Array[Int]]): Arr[Array[Int]] = | ||
new Arr(x.value) | ||
|
||
def arr4(x: Arr[Array[String]]): Arr[Array[String]] = | ||
new Arr(x.value) | ||
|
||
def arrRef1(x: ArrRef[Integer]): ArrRef[Integer] = | ||
new ArrRef(x.value) | ||
|
||
def arrRef2(x: ArrRef[String]): ArrRef[String] = | ||
new ArrRef(x.value) | ||
|
||
def arrRef3(x: ArrRef[Array[Int]]): ArrRef[Array[Int]] = | ||
new ArrRef(x.value) | ||
|
||
def arrRef4(x: ArrRef[Array[String]]): ArrRef[Array[String]] = | ||
new ArrRef(x.value) | ||
} |
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,20 @@ | ||
object B { | ||
def main(args: Array[String]): Unit = { | ||
val a = new A | ||
|
||
a.poly1(new Poly(1)) | ||
a.poly2(new Poly("")) | ||
a.poly3(new Poly(Array(1))) | ||
a.poly4(new Poly(Array(""))) | ||
|
||
a.arr1(new Arr(Array(1))) | ||
a.arr2(new Arr(Array(""))) | ||
a.arr3(new Arr(Array(Array(1)))) | ||
a.arr4(new Arr(Array(Array("")))) | ||
|
||
a.arrRef1(new ArrRef(Array(1))) | ||
a.arrRef2(new ArrRef(Array(""))) | ||
a.arrRef3(new ArrRef(Array(Array(1)))) | ||
a.arrRef4(new ArrRef(Array(Array("")))) | ||
} | ||
} |
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 @@ | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version")) |
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 @@ | ||
> test/run |
File renamed without changes.
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
class Test2(val valueVal: Test2) extends AnyVal // error: value class cannot wrap itself | ||
class Test0(val valueVal: Test0) extends AnyVal // error: value class cannot wrap itself | ||
|
||
class Test1(val x: Int) extends AnyVal | ||
class Test2(val y: Test1) extends AnyVal // error: value class may not wrap another user-defined value 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.