File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -2011,12 +2011,16 @@ class Typer extends Namer
20112011 typed(innerExpr, pt)
20122012 case expr =>
20132013 if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 ) {
2014- fullyDefinedType(pt, " quoted pattern selector" , tree.span)
2015- def spliceOwner (ctx : Context ): Symbol =
2016- if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
2017- val pat = typedPattern(expr, defn.QuotedExprType .appliedTo(pt))(
2018- spliceContext.retractMode(Mode .QuotedPattern ).withOwner(spliceOwner(ctx)))
2019- Splice (pat)
2014+ if (isFullyDefined(pt, ForceDegree .all)) {
2015+ def spliceOwner (ctx : Context ): Symbol =
2016+ if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
2017+ val pat = typedPattern(expr, defn.QuotedExprType .appliedTo(pt))(
2018+ spliceContext.retractMode(Mode .QuotedPattern ).withOwner(spliceOwner(ctx)))
2019+ Splice (pat)
2020+ } else {
2021+ ctx.error(i " Type must be fully defined. \n Consider annotating the splice using a type ascription: \n ( $tree: XYZ). " , expr.sourcePos)
2022+ tree.withType(UnspecifiedErrorType )
2023+ }
20202024 }
20212025 else
20222026 typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprSpliceR ), tree.expr), pt)(spliceContext).withSpan(tree.span)
Original file line number Diff line number Diff line change 1+ class Test {
2+ def res (x : quoted.Expr [Int ]) given tasty .Reflection : quoted.Expr [Int ] = x match {
3+ case ' { 1 + $b } => // error: Type must be fully defined. Consider annotating the splice using a type ascription: (${b}: XYZ).
4+ b // error: Not found: b
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments