New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dealias val aliases to modules so they're =:= #9313
Conversation
Here's an example. In 2.13.3: scala> :power
scala> import reflect.internal.util.{shortClassOfInstance => c}
scala> object O; val x: O.type = O
object O
val x: O.type = O$@1545b9da
scala> val oSingle = typeOf[O.type]; println(c(oSingle))
UniqueSingleType
val oSingle: $r.intp.global.Type = O.type
scala> val oModule = oSingle.underlying; println(c(oModule))
ModuleTypeRef
val oModule: $r.intp.global.Type = O.type
scala> val xSingle = typeOf[x.type]; println(c(xSingle))
UniqueSingleType
val xSingle: $r.intp.global.Type = x.type
scala> xSingle =:= oSingle
val res3: Boolean = true
scala> xSingle =:= oModule
val res4: Boolean = false This PR fixes the last line. |
We should unit test this by adding some test cases to
See the previous tweaks to |
e.g. diff --git a/test/junit/scala/reflect/internal/TypesTest.scala b/test/junit/scala/reflect/internal/TypesTest.scala
index ab0cdd954e..fc30775b4a 100644
--- a/test/junit/scala/reflect/internal/TypesTest.scala
+++ b/test/junit/scala/reflect/internal/TypesTest.scala
@@ -46,9 +46,15 @@ class TypesTest {
val tp1 = TypeRef(ThisType(EmptyPackageClass), moduleClass, Nil)
val tp2 = SingleType(ThisType(EmptyPackageClass), module)
val tp3 = ThisType(moduleClass)
- val tps = List(tp1, tp2, tp3)
+
+ val (otherModule, otherModuleClass) = EmptyPackageClass.newModuleAndClassSymbol(TermName("Other"), NoPosition, 0L)
+ val aliasSym = otherModuleClass.newTermSymbol(TermName("alias")).setInfo(tp2)
+ val tp4 = singleType(TypeRef(ThisType(EmptyPackageClass), otherModuleClass, Nil), aliasSym)
+
+
+ val tps = List(tp1, tp2, tp3, tp4)
val results = mutable.Buffer[String]()
- tps.permutations.foreach {
+ tps.combinations(3).foreach {
case ts @ List(a, b, c) =>
def tsShownRaw = ts.map(t => showRaw(t)).mkString(", ")
if (a <:< b && b <:< c && !(a <:< c)) results += s"<:< intransitive: $tsShownRaw"
|
ae5f764
to
2eeada6
Compare
Thanks, Jason. I was getting some detail there wrong so I was struggling. Yours works very well, failing without the patch. |
2eeada6
to
de23b34
Compare
This changes the definitely of =:= in the smallest possible way: if you have a singleton type that widens to a module, then widen to that module.
de23b34
to
53fad3d
Compare
Briefly touched on this one with Adriaan and he said he agrees that |
This changes the definition of
=:=
in the smallest possible way:if you have a singleton type that widens to a module,
then widen to that module.
Fixes scala/bug#12186.