Skip to content

Evolving Tasty definitions #4286

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
Apr 10, 2018
Merged
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
38 changes: 6 additions & 32 deletions tests/pos/TastyADT.scala → tests/pos/tasty/definitions.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
object tasty {
package tasty

object definitions {

// ------ Names --------------------------------

Expand All @@ -8,16 +10,13 @@ object tasty {
enum TermName extends Name with PossiblySignedName {
case Simple(str: String)
case Qualified(prefix: TermName, selector: String) // s"$prefix.$name"
case Unique(underlying: TermName, separator: String, idx: Int) // s"$underlying$separator$idx"

case DefaultGetter(methodName: TermName, idx: String) // s"$methodName${"$default$"}${idx+1}"
case Variant(underlying: TermName, covariant: Boolean) // s"${if (covariant) "+" else "-"}$underlying"
case SuperAccessor(underlying: TermName) // s"${"super$"}$underlying"
case ProtectedAccessor(underlying: TermName) // s"${"protected$"}$underlying"
case ProtectedSetter(underlying: TermName) // s"${"protected$set"}$underlying"
case ObjectClass(underlying: TermName) // s"$underlying${"$"}"

case Expanded(prefix: TermName, selector: String) // s"$prefix${"$$"}$name" , used only for symbols coming from Scala 2
case ExpandedPrefix(prefix: TermName, selector: String) // s"$prefix${"$"}$name" , used only for symbols coming from Scala 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can we remove these ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are Scala2 interop only. I am not sure we need to expose these to macro writers. So I propose we just present the mangled names.

}

case class SignedName(name: TermName, resultSig: TypeName, paramSigs: List[TypeName]) extends PossiblySignedName
Expand Down Expand Up @@ -131,7 +130,7 @@ object tasty {
case class SymRef(sym: Definition, qualifier: Type | NoPrefix = NoPrefix) extends Type
case class NameRef(name: Name, qualifier: Type | NoPrefix = NoPrefix) extends Type // NoPrefix means: select from _root_
case class SuperType(thistp: Type, underlying: Type) extends Type
case class Refinement(underlying: Type, name: Name, tpe: Type) extends Type
case class Refinement(underlying: Type, name: Name, tpe: Type | TypeBounds) extends Type
case class AppliedType(tycon: Type, args: List[Type | TypeBounds]) extends Type
case class AnnotatedType(underlying: Type, annotation: Term) extends Type
case class AndType(left: Type, right: Type) extends Type
Expand All @@ -153,7 +152,7 @@ object tasty {

abstract class LambdaType[ParamName, ParamInfo, This <: LambdaType[ParamName, ParamInfo, This]](
val companion: LambdaTypeCompanion[ParamName, ParamInfo, This]
) {
) extends Type {
private[Type] var _pinfos: List[ParamInfo]
private[Type] var _restpe: Type

Expand Down Expand Up @@ -247,28 +246,3 @@ object tasty {
case Enum(v: Type) extends Constant(v)
}
}

object Test {
import tasty._
import Type._

def show(tp: Type): String = tp match {
case ConstantType(c) => c.value.toString
case SymRef(sym, NoPrefix) => ???
case SymRef(sym, t: Type) => ???
case NameRef(name: Name, qualifier) => ???
case SuperType(thistp: Type, underlying: Type) => ???
case Refinement(underlying: Type, name: Name, tpe: Type) => ???
case AppliedType(tycon, args) => ???
case AnnotatedType(underlying: Type, annotation: Term) => ???
case AndType(left: Type, right: Type) => ???
case OrType(left: Type, right: Type) => ???
case ByNameType(underlying: Type) => ???
case ParamRef(binder, idx) => ???
case RecursiveThis(binder: RecursiveType) => ???
case RecursiveType(tp) => ???
case MethodType(pnames, ptypes, resType) => ???
case PolyType(pnames, ptypes, resType) => ???
case TypeLambda(pnames, ptypes, resType) => ???
}
}