-
Notifications
You must be signed in to change notification settings - Fork 184
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
Add resultType extension method on Symbol #381
Conversation
for { | ||
symbol <- t.symbol | ||
resultType <- symbol.resultType | ||
} yield assert(resultType.structure == Type.Name("Boolean").structure) |
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.
is there a smarter way to compare trees?
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.
There is! import scala.meta.contrib._; q"a.b".isEqual(q"a.b.")
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.
thanks! I'll fix it
val defaultDialect = | ||
dialects.Scala212.copy(allowMethodTypes = true, allowTypeLambdas = true) | ||
|
||
def resultType( |
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 name is up to debate. resultType
is general enough, but it's a bit of a stretch when referring to simple val
/var
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.
Result type is the correct nomenclature from scalac 👍
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 👍 besides the minor comments
val defaultDialect = | ||
dialects.Scala212.copy(allowMethodTypes = true, allowTypeLambdas = true) | ||
|
||
def resultType( |
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.
Result type is the correct nomenclature from scalac 👍
def resultType(dialect: Dialect): Option[Type] = | ||
denotation.flatMap(denot => | ||
DenotationOps.resultType(symbol, denot, dialect)) | ||
def resultType: Option[Type] = resultType(DenotationOps.defaultDialect) |
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.
Can we only keep this overload and let advanced users with custom dialects call DenotationOps.resultType(customDialect)
?
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.
fine by me
for { | ||
symbol <- t.symbol | ||
resultType <- symbol.resultType | ||
} yield assert(resultType.structure == Type.Name("Boolean").structure) |
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.
There is! import scala.meta.contrib._; q"a.b".isEqual(q"a.b.")
We should filter out We need to upgrade Mima to 0.1.15 Line 17 in 6b8cccd
|
@olafurpg I've added the mima change in this PR, so that we can test it on the spot. Hope you don't mind |
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.
Absolutely, it's fine to do the mima changes here
This seemed like a useful utility so I extracted it from
ExplicitResultTypes