@@ -98,7 +98,7 @@ trait QuotesAndSplices {
98
98
case _ =>
99
99
}
100
100
if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 )
101
- if (isFullyDefined(pt, ForceDegree .all)) {
101
+ if (false && isFullyDefined(pt, ForceDegree .all)) {
102
102
ctx.error(i " Spliced type pattern must not be fully defined. Consider using $pt directly " , tree.expr.sourcePos)
103
103
tree.withType(UnspecifiedErrorType )
104
104
}
@@ -111,7 +111,10 @@ trait QuotesAndSplices {
111
111
ctx.error(" expected a name binding" , expr.sourcePos)
112
112
" $error" .toTypeName
113
113
}
114
- val typeSym = ctx.newSymbol(spliceOwner(ctx), name, EmptyFlags , TypeBounds .empty, NoSymbol , tree.expr.span)
114
+ val typeSymInfo = pt match
115
+ case pt : TypeBounds => pt
116
+ case _ => TypeBounds .empty
117
+ val typeSym = ctx.newSymbol(spliceOwner(ctx), name, EmptyFlags , typeSymInfo, NoSymbol , tree.expr.span)
115
118
typeSym.addAnnotation(Annotation (New (ref(defn.InternalQuoted_patternBindHoleAnnot .typeRef)).withSpan(tree.expr.span)))
116
119
val pat = typedPattern(tree.expr, defn.QuotedTypeClass .typeRef.appliedTo(typeSym.typeRef))(
117
120
spliceContext.retractMode(Mode .QuotedPattern ).withOwner(spliceOwner(ctx)))
@@ -317,13 +320,16 @@ trait QuotesAndSplices {
317
320
ctx.error(missingArgMsg(qctx, defn.QuoteContextClass .typeRef, " " ), ctx.source.atSpan(tree.span))
318
321
319
322
val quoted = tree.quoted
320
- val exprPt = pt.baseType(defn.QuotedExprClass )
323
+ val exprPt = pt.baseType(if quoted.isType then defn. QuotedTypeClass else defn.QuotedExprClass )
321
324
val quotedPt = exprPt.argInfos.headOption match {
322
325
case Some (argPt : ValueType ) => argPt // excludes TypeBounds
323
326
case _ => defn.AnyType
324
327
}
325
328
val quoted0 = desugar.quotedPattern(quoted, untpd.TypedSplice (TypeTree (quotedPt)))
326
- val quoted1 = typedExpr(quoted0, WildcardType )(quoteContext.addMode(Mode .QuotedPattern ))
329
+ val quoteCtx = quoteContext.addMode(Mode .QuotedPattern )
330
+ val quoted1 =
331
+ if quoted.isType then typedType(quoted0, quotedPt)(quoteCtx)
332
+ else typedExpr(quoted0, quotedPt)(quoteCtx)
327
333
328
334
val (typeBindings, shape, splices) = splitQuotePattern(quoted1)
329
335
0 commit comments