Skip to content

erase scala.AnyKind to scala.Any #101

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

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/tasty/bridge/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
12 changes: 8 additions & 4 deletions src/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/neg/src-2/TestCompiletimeQuoteType.check
Original file line number Diff line number Diff line change
@@ -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