diff --git a/src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala b/src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala index 3af3692a472d..4aca0111088a 100644 --- a/src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala +++ b/src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala @@ -45,6 +45,7 @@ trait NameOps { self: TastyUniverse => object tpnme { final val Or: TypeName = TastyName.SimpleName("|").toTypeName final val And: TypeName = TastyName.SimpleName("&").toTypeName + final val AnyKind: TypeName = TastyName.SimpleName("AnyKind").toTypeName final val ScalaAnnotationInternal_Repeated: TypeName = TastyName.qualifiedClass("scala", "annotation", "internal", "Repeated") diff --git a/src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala b/src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala index c02b068d0f09..9c213cdc65f7 100644 --- a/src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala +++ b/src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala @@ -72,7 +72,7 @@ trait TreeOps { self: TastyUniverse => def SeqLiteral(trees: List[Tree], tpt: Tree): Tree = u.ArrayValue(tpt, trees).setType(tpt.tpe) def AppliedTypeTree(tpt: Tree, args: List[Tree])(implicit ctx: Context): Tree = { - if (tpt.tpe === AndType) { + if (tpt.tpe === AndTpe) { u.CompoundTypeTree(u.Template(args, u.noSelfType, Nil)).setType(ui.intersectionType(args.map(_.tpe))) } else { u.AppliedTypeTree(tpt, args).setType(defn.AppliedType(tpt.tpe, args.map(_.tpe))) diff --git a/src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala b/src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala index 0897490e50c6..d296a15811da 100644 --- a/src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala +++ b/src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala @@ -238,15 +238,19 @@ trait TypeOps { self: TastyUniverse => } - /** A type which accepts two type arguments, representing an intersection type + /** A synthetic type `scala.&` which accepts two type arguments, representing an intersection type * @see https://github.com/lampepfl/dotty/issues/7688 */ - case object AndType extends Type + case object AndTpe extends Type def selectType(name: TastyName.TypeName, prefix: Type)(implicit ctx: Context): Type = selectType(name, prefix, prefix) def selectType(name: TastyName.TypeName, prefix: Type, space: Type)(implicit ctx: Context): Type = { - if (prefix.typeSymbol === u.definitions.ScalaPackage && ( name === tpnme.And || name === tpnme.Or ) ) { - if (name === tpnme.And) AndType + if (prefix.typeSymbol === u.definitions.ScalaPackage && ( + name === tpnme.And + || name === tpnme.Or + || name === tpnme.AnyKind) ) { + if (name === tpnme.And) AndTpe + 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 else unionIsUnsupported } else { diff --git a/test/tasty/neg/src-2/TestCompiletimeQuoteType.check b/test/tasty/neg/src-2/TestCompiletimeQuoteType.check index 65c9dd9e1a38..5c2f3c01b8df 100644 --- a/test/tasty/neg/src-2/TestCompiletimeQuoteType.check +++ b/test/tasty/neg/src-2/TestCompiletimeQuoteType.check @@ -1,4 +1,4 @@ -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. +TestCompiletimeQuoteType_fail.scala:4: error: could not find implicit value for evidence parameter of type scala.quoted.Type[Int] def test = CompiletimeQuoteType.f[Int] ^ 1 error