-
Notifications
You must be signed in to change notification settings - Fork 22
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
Clean up macros; Support reflection #24
Conversation
c0edce0
to
e2e0d5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
)(tpe: Type): Either[Id[String], List[Type]] = | ||
typeListFoldLeft(nilTpe, consTpe)(tpe)(List.empty[Type])((acc, t) => t :: acc).map(_.reverse) | ||
|
||
final def tlistTypes(tpe: Type): Either[Id[String], List[Type]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final def destructCop(tpe: Type): Either[Id[String], CopTypes] = | ||
tpe.dealias match { | ||
case TypeRef(_, sym, l :: Nil) if resultType(sym) <:< CopTpe => Right(CopTypes(l)) | ||
case TypeRef(_, sym, Nil) => destructCop(sym.asType.toType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not have sym.typeSignature
assuming this is a TypeSymbol
? sym.asType.toType
can throw scala.ScalaReflectionException
as far as I know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked-- .typeSignature
gives a different result than .asType.toType
, and it causes the tests to fail. I'm going to sort out what the differences are and look at cleaning this up, regardless!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andyscott I accept I am wrong here, I just didn't know the API differences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feedback was very welcomed regardless! I didn't know about (or hadn't used) .typeSignature
before; now I I'll use it next time I'm poking around.
final def destructCopK(tpe: Type): Either[Id[String], CopKTypes] = | ||
tpe.dealias match { | ||
case TypeRef(_, sym, l :: a :: Nil) if resultType(sym) <:< CopKTpe => Right(CopKTypes(l, a)) | ||
case TypeRef(_, sym, Nil) => destructCopK(sym.asType.toType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this is in effect, tpe.dealias
no? I'm not sure what kind of magic unapply does, but I do know weakTypeOf[T].termSymbol.asType.toType
blows up.
|
||
import scala.reflect.macros.blackbox.Context | ||
|
||
private[iota] final class TypeListMacros(cc: Context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird alignment I think, but I'm not sure if this is your standard scalaFMT and I just have different habits. I would expect:
class A(
..args
) extends Bla {
}
e2e0d5d
to
dac1959
Compare
No description provided.