Skip to content

Commit

Permalink
Resolve some todos
Browse files Browse the repository at this point in the history
  • Loading branch information
zeptometer committed Aug 19, 2023
1 parent 17dfdbd commit 11fdce9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
val close = if (body.isTerm) keywordStr("}") else keywordStr("]")
keywordStr("'") ~ quotesText ~ open ~ bindingsText ~ toTextGlobal(body) ~ close
case SplicePattern(pattern, typeargs, args) =>
// TODO-18271: Add tests?
val spliceTypeText = (keywordStr("[") ~ toTextGlobal(tree.typeOpt) ~ keywordStr("]")).provided(printDebug && tree.typeOpt.exists)
keywordStr("$") ~ spliceTypeText ~ {
if typeargs.isEmpty && args.isEmpty then keywordStr("{") ~ inPattern(toText(pattern)) ~ keywordStr("}")
Expand Down
9 changes: 1 addition & 8 deletions compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ trait QuotesAndSplices {
val typedTypeargs = tree.typeargs.map {
case typearg: untpd.Ident =>
val typedTypearg = typedType(typearg)
/* TODO-18271: Allow type bounds?
* (NOTE: Needs non-trivial extension to type system)
*/
val bounds = ctx.gadt.fullBounds(typedTypearg.symbol)
if bounds != null && bounds != TypeBounds.empty then
report.error("Implementation restriction: Type arguments to Open pattern are expected to have no bounds", typearg.srcPos)
Expand Down Expand Up @@ -179,17 +176,14 @@ trait QuotesAndSplices {
/** Types a splice applied to some type arguments and arguments
* `$f[targs1, ..., targsn](arg1, ..., argn)` in a quote pattern.
*
* TODO-18217: Remove follwing notes on complete
* Refer to: typedTypeApply
* Refer to: typedAppliedSplice
*/
def typedAppliedSpliceWithTypes(tree: untpd.Apply, pt: Type)(using Context): Tree = {
assert(ctx.mode.isQuotedPattern)
val untpd.Apply(typeApplyTree @ untpd.TypeApply(splice: untpd.SplicePattern, typeargs), args) = tree: @unchecked
def isInBraces: Boolean = splice.span.end != splice.body.span.end
if isInBraces then // ${x}[...](...) match an application
// TODO-18127: typedTypeApply cares about named arguments. Do we want to care as well?
val typedTypeargs = typeargs.map(arg => typedType(arg))
// TODO-18217: Why do we use typedExpr here?
val typedArgs = args.map(arg => typedExpr(arg))
val argTypes = typedArgs.map(_.tpe.widenTermRefExpr)
val splice1 = typedSplicePattern(splice, ProtoTypes.PolyProto(typedArgs, defn.FunctionOf(argTypes, pt)))
Expand All @@ -198,7 +192,6 @@ trait QuotesAndSplices {
else // $x[...](...) higher-order quasipattern
// Empty args is allowed
if typeargs.isEmpty then
// TODO-18271: Better error message
report.error("Missing type arguments for open pattern", tree.srcPos)
typedSplicePattern(untpd.cpy.SplicePattern(tree)(splice.body, typeargs, args), pt)
}
Expand Down

0 comments on commit 11fdce9

Please sign in to comment.