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