@@ -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
case Bind (name, _) => (" $" + name).toTypeName
112
112
case _ => NameKinds .UniqueName .fresh(" $" .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)))
@@ -318,13 +321,16 @@ trait QuotesAndSplices {
318
321
ctx.error(missingArgMsg(qctx, defn.QuoteContextClass .typeRef, " " ), ctx.source.atSpan(tree.span))
319
322
320
323
val quoted = tree.quoted
321
- val exprPt = pt.baseType(defn.QuotedExprClass )
324
+ val exprPt = pt.baseType(if quoted.isType then defn. QuotedTypeClass else defn.QuotedExprClass )
322
325
val quotedPt = exprPt.argInfos.headOption match {
323
326
case Some (argPt : ValueType ) => argPt // excludes TypeBounds
324
327
case _ => defn.AnyType
325
328
}
326
329
val quoted0 = desugar.quotedPattern(quoted, untpd.TypedSplice (TypeTree (quotedPt)))
327
- val quoted1 = typedExpr(quoted0, WildcardType )(quoteContext.addMode(Mode .QuotedPattern ))
330
+ val quoteCtx = quoteContext.addMode(Mode .QuotedPattern )
331
+ val quoted1 =
332
+ if quoted.isType then typedType(quoted0, quotedPt)(quoteCtx)
333
+ else typedExpr(quoted0, quotedPt)(quoteCtx)
328
334
329
335
val (typeBindings, shape, splices) = splitQuotePattern(quoted1)
330
336
0 commit comments