Skip to content

Commit fb0ef91

Browse files
authored
Merge pull request #101 from scalacenter/tasty/support-anykind
erase scala.AnyKind to scala.Any
2 parents b0627d0 + 9a72ec7 commit fb0ef91

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ trait NameOps { self: TastyUniverse =>
4545
object tpnme {
4646
final val Or: TypeName = TastyName.SimpleName("|").toTypeName
4747
final val And: TypeName = TastyName.SimpleName("&").toTypeName
48+
final val AnyKind: TypeName = TastyName.SimpleName("AnyKind").toTypeName
4849

4950
final val ScalaAnnotationInternal_Repeated: TypeName =
5051
TastyName.qualifiedClass("scala", "annotation", "internal", "Repeated")

src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ trait TreeOps { self: TastyUniverse =>
7272
def SeqLiteral(trees: List[Tree], tpt: Tree): Tree = u.ArrayValue(tpt, trees).setType(tpt.tpe)
7373

7474
def AppliedTypeTree(tpt: Tree, args: List[Tree])(implicit ctx: Context): Tree = {
75-
if (tpt.tpe === AndType) {
75+
if (tpt.tpe === AndTpe) {
7676
u.CompoundTypeTree(u.Template(args, u.noSelfType, Nil)).setType(ui.intersectionType(args.map(_.tpe)))
7777
} else {
7878
u.AppliedTypeTree(tpt, args).setType(defn.AppliedType(tpt.tpe, args.map(_.tpe)))

src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,19 @@ trait TypeOps { self: TastyUniverse =>
238238

239239
}
240240

241-
/** A type which accepts two type arguments, representing an intersection type
241+
/** A synthetic type `scala.&` which accepts two type arguments, representing an intersection type
242242
* @see https://github.com/lampepfl/dotty/issues/7688
243243
*/
244-
case object AndType extends Type
244+
case object AndTpe extends Type
245245

246246
def selectType(name: TastyName.TypeName, prefix: Type)(implicit ctx: Context): Type = selectType(name, prefix, prefix)
247247
def selectType(name: TastyName.TypeName, prefix: Type, space: Type)(implicit ctx: Context): Type = {
248-
if (prefix.typeSymbol === u.definitions.ScalaPackage && ( name === tpnme.And || name === tpnme.Or ) ) {
249-
if (name === tpnme.And) AndType
248+
if (prefix.typeSymbol === u.definitions.ScalaPackage && (
249+
name === tpnme.And
250+
|| name === tpnme.Or
251+
|| name === tpnme.AnyKind) ) {
252+
if (name === tpnme.And) AndTpe
253+
else if (name === tpnme.AnyKind) u.definitions.AnyTpe // TODO [tasty]: scala.AnyKind can appear in upper bounds of raw type wildcards, but elsewhere it is unclear if it should be erased or error
250254
else unionIsUnsupported
251255
}
252256
else {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TestCompiletimeQuoteType_fail.scala:4: error: can't find type required by type parameter T in class scala.quoted.Type: scala.AnyKind; perhaps it is missing from the classpath.
1+
TestCompiletimeQuoteType_fail.scala:4: error: could not find implicit value for evidence parameter of type scala.quoted.Type[Int]
22
def test = CompiletimeQuoteType.f[Int]
33
^
44
1 error

0 commit comments

Comments
 (0)