Skip to content

Commit df50160

Browse files
committed
chore: do not assume scala types as transparent, source should enforce it
1 parent 5ac8a32 commit df50160

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ class Definitions {
278278
* To achieve this, we synthesize all Any and Object methods; Object methods no longer get
279279
* loaded from a classfile.
280280
*/
281-
@tu lazy val AnyClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Any, Abstract, Nil), ensureCtor = false)
281+
@tu lazy val AnyClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Any, Abstract | TransparentType, Nil), ensureCtor = false)
282282
def AnyType: TypeRef = AnyClass.typeRef
283-
@tu lazy val MatchableClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Matchable, Trait, AnyType :: Nil), ensureCtor = false)
283+
@tu lazy val MatchableClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Matchable, Trait | TransparentType, AnyType :: Nil), ensureCtor = false)
284284
def MatchableType: TypeRef = MatchableClass.typeRef
285285
@tu lazy val AnyValClass: ClassSymbol =
286-
val res = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.AnyVal, Abstract, List(AnyType, MatchableType)))
286+
val res = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.AnyVal, Abstract | TransparentType, List(AnyType, MatchableType)))
287287
// Mark companion as absent, so that class does not get re-completed
288288
val companion = ScalaPackageVal.info.decl(nme.AnyVal).symbol
289289
companion.moduleClass.markAbsent()
@@ -2049,42 +2049,12 @@ class Definitions {
20492049
(sym eq Object_eq) || (sym eq Object_ne)
20502050

20512051
@tu lazy val assumedTransparentNames: Map[Name, Set[Symbol]] =
2052-
// add these for now, until we had a chance to retrofit 2.13 stdlib
20532052
// we should do a more through sweep through it then.
20542053
val strs = Map(
2055-
"Any" -> Set("scala"),
2056-
"AnyVal" -> Set("scala"),
2057-
"Matchable" -> Set("scala"),
2058-
"Product" -> Set("scala"),
20592054
"Object" -> Set("java.lang"),
20602055
"Comparable" -> Set("java.lang"),
20612056
"Serializable" -> Set("java.io"),
2062-
"BitSetOps" -> Set("scala.collection"),
2063-
"IndexedSeqOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2064-
"IterableOnceOps" -> Set("scala.collection"),
2065-
"IterableOps" -> Set("scala.collection"),
2066-
"LinearSeqOps" -> Set("scala.collection", "scala.collection.immutable"),
2067-
"MapOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2068-
"SeqOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2069-
"SetOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2070-
"SortedMapOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2071-
"SortedOps" -> Set("scala.collection"),
2072-
"SortedSetOps" -> Set("scala.collection", "scala.collection.mutable", "scala.collection.immutable"),
2073-
"StrictOptimizedIterableOps" -> Set("scala.collection"),
2074-
"StrictOptimizedLinearSeqOps" -> Set("scala.collection"),
2075-
"StrictOptimizedMapOps" -> Set("scala.collection", "scala.collection.immutable"),
2076-
"StrictOptimizedSeqOps" -> Set("scala.collection", "scala.collection.immutable"),
2077-
"StrictOptimizedSetOps" -> Set("scala.collection", "scala.collection.immutable"),
2078-
"StrictOptimizedSortedMapOps" -> Set("scala.collection", "scala.collection.immutable"),
2079-
"StrictOptimizedSortedSetOps" -> Set("scala.collection", "scala.collection.immutable"),
2080-
"ArrayDequeOps" -> Set("scala.collection.mutable"),
2081-
"DefaultSerializable" -> Set("scala.collection.generic"),
2082-
"IsIterable" -> Set("scala.collection.generic"),
2083-
"IsIterableLowPriority" -> Set("scala.collection.generic"),
2084-
"IsIterableOnce" -> Set("scala.collection.generic"),
2085-
"IsIterableOnceLowPriority" -> Set("scala.collection.generic"),
2086-
"IsMap" -> Set("scala.collection.generic"),
2087-
"IsSeq" -> Set("scala.collection.generic"))
2057+
)
20882058
strs.map { case (simple, pkgs) => (
20892059
simple.toTypeName,
20902060
pkgs.map(pkg => staticRef(pkg.toTermName, isPackage = true).symbol.moduleClass)

0 commit comments

Comments
 (0)