Skip to content

Fix TASTy Reflect IsInstanceOf[Type] #7587

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
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
16 changes: 8 additions & 8 deletions library/src/scala/tasty/reflect/SourceCodePrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
printType(lo)
this += " <: "
printType(hi)
case IsType(tpe) => printType(tpe)
case tpe: Type => printType(tpe)
}

/** Print type
Expand Down Expand Up @@ -1089,7 +1089,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
this += "#"
case ThisType(TermRef(cdef, _)) if elideThis.nonEmpty && cdef == elideThis.get =>
case ThisType(TypeRef(cdef, _)) if elideThis.nonEmpty && cdef == elideThis.get =>
case IsType(prefix) =>
case prefix: Type =>
printType(prefix)
this += "."
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
case ByNameType(t) =>
this += ": "
printType(t)
case IsType(tp) =>
case tp: Type =>
this += ": "
printType(tp)
}
Expand All @@ -1282,7 +1282,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
case ByNameType(_) | MethodType(_, _, _) | TypeLambda(_, _, _) =>
this += highlightKeyword("def ") += highlightTypeDef(name)
printMethodicType(info)
case IsType(info) =>
case info: Type =>
this += highlightKeyword("val ") += highlightValDef(name)
printMethodicType(info)
}
Expand All @@ -1298,7 +1298,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
def printMethodicTypeParams(paramNames: List[String], params: List[TypeOrBounds])(given elideThis: Option[Symbol]): Unit = {
def printInfo(info: TypeOrBounds) = info match {
case info: TypeBounds => printBounds(info)
case IsType(info) =>
case info: Type =>
this += ": "
printType(info)
}
Expand Down Expand Up @@ -1444,8 +1444,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig

object Sequence {
def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match {
case AppliedType(TypeRef(prefix: TermRef, "Seq"), IsType(tp) :: Nil) if prefix.termSymbol.fullName == "scala.collection" => Some(tp)
case AppliedType(TypeRef(prefix: TypeRef, "Seq"), IsType(tp) :: Nil) if prefix.typeSymbol.fullName == "scala.collection" => Some(tp)
case AppliedType(TypeRef(prefix: TermRef, "Seq"), (tp: Type) :: Nil) if prefix.termSymbol.fullName == "scala.collection" => Some(tp)
case AppliedType(TypeRef(prefix: TypeRef, "Seq"), (tp: Type) :: Nil) if prefix.typeSymbol.fullName == "scala.collection" => Some(tp)
case _ => None
}
}
Expand All @@ -1460,7 +1460,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig

object Repeated {
def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match {
case AppliedType(TypeRef(ScalaPackage(), "<repeated>"), IsType(tp) :: Nil) => Some(tp)
case AppliedType(TypeRef(ScalaPackage(), "<repeated>"), (tp: Type) :: Nil) => Some(tp)
case _ => None
}
}
Expand Down
8 changes: 3 additions & 5 deletions library/src/scala/tasty/reflect/TypeOrBoundsOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ trait TypeOrBoundsOps extends Core {
def isDependentFunctionType(given ctx: Context): Boolean = internal.Type_isDependentFunctionType(self)
}

// FIXME: needs #7532 fixed in the reference compiler
// given (given Context): IsInstanceOf[Type] = internal.isInstanceOfType
given (given Context): IsInstanceOf[Type] = internal.isInstanceOfType

object IsType
// FIXME: Add depecation. Needs #7532 fixed in the reference compiler
// @deprecated("Use _: Type", "")
def unapply(x: TypeOrBounds)(given ctx: Context): Option[Type] =
@deprecated("Use _: Type", "")
def unapply(x: Type)(given ctx: Context): Option[Type] =
internal.isInstanceOfType.unapply(x)

object Type {
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object MyScalaJSPlugin extends AutoPlugin {
}

object Build {
val referenceVersion = "0.20.0-RC1"
val referenceVersion = "0.21.0-bin-20191119-7c7fffa-NIGHTLY"

val baseVersion = "0.21.0"
val baseSbtDottyVersion = "0.3.5"
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/tasty-simplified/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object Macros {
def unpackTuple(tp: Type): List[Type] = {
@tailrec
def loop(tp: Type, acc: List[Type]): List[Type] = tp.dealias.simplified match {
case AppliedType(_, List(IsType(hd), IsType(tl))) =>
case AppliedType(_, List(hd: Type, tl: Type)) =>
loop(tl, hd.dealias.simplified :: acc)
case other => acc
}
Expand Down