@@ -657,32 +657,37 @@ object TreeChecker {
657
657
658
658
// Check that we only add the captured type `T` instead of a more complex type like `List[T]`.
659
659
// If we have `F[T]` with captured `F` and `T`, we should list `F` and `T` separately in the args.
660
- for arg <- (targs ::: args) do // TODO check targs and terms separately
661
- assert(arg.isTerm || arg.tpe.isInstanceOf [TypeRef ], " Expected TypeRef in Hole type args but got: " + arg.tpe)
660
+ for targ <- targs do
661
+ assert(targ.isType)
662
+ assert(targ.tpe.isInstanceOf [TypeRef ], " Expected TypeRef in Hole targs but got: " + targ.tpe)
663
+ for arg <- args do
664
+ assert(arg.isTerm)
665
+ assert(arg.isInstanceOf [RefTree ], " Expected RefTree in Hole args but got: " + arg)
662
666
663
667
// Check result type of the hole
664
668
if isTermHole then assert(tpt.typeOpt <:< pt)
665
669
else assert(tpt.typeOpt =:= pt)
666
670
667
671
// Check that the types of the args conform to the types of the contents of the hole
668
- val argQuotedTypes = (targs ::: args).map { arg =>
669
- if arg.isTerm then
670
- val tpe = arg.typeOpt.widenTermRefExpr match
671
- case _ : MethodicType =>
672
- // Special erasure for captured function references
673
- // See `SpliceTransformer.transformCapturedApplication`
674
- defn.AnyType
675
- case tpe => tpe
676
- defn.QuotedExprClass .typeRef.appliedTo(tpe)
677
- else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt)
672
+ val targQuotedTypes = targs.map { arg =>
673
+ defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt)
674
+ }
675
+ val argQuotedTypes = args.map { arg =>
676
+ val tpe = arg.typeOpt.widenTermRefExpr match
677
+ case _ : MethodicType =>
678
+ // Special erasure for captured function references
679
+ // See `SpliceTransformer.transformCapturedApplication`
680
+ defn.AnyType
681
+ case tpe => tpe
682
+ defn.QuotedExprClass .typeRef.appliedTo(tpe)
678
683
}
679
684
val expectedResultType =
680
685
if isTermHole then defn.QuotedExprClass .typeRef.appliedTo(tpt.typeOpt)
681
686
else defn.QuotedTypeClass .typeRef.appliedTo(tpt.typeOpt)
682
687
val contextualResult =
683
688
defn.FunctionOf (List (defn.QuotesClass .typeRef), expectedResultType, isContextual = true )
684
689
val expectedContentType =
685
- defn.FunctionOf (argQuotedTypes, contextualResult)
690
+ defn.FunctionOf (targQuotedTypes ::: argQuotedTypes, contextualResult)
686
691
assert(content.typeOpt =:= expectedContentType, i " expected content of the hole to be ${expectedContentType} but got ${content.typeOpt}" )
687
692
688
693
tree1
0 commit comments