@@ -1552,8 +1552,9 @@ class Typer extends Namer
1552
1552
}
1553
1553
1554
1554
def typedBind (tree : untpd.Bind , pt : Type )(implicit ctx : Context ): Tree = {
1555
- val pt1 = fullyDefinedType(pt, " pattern variable" , tree.span)
1556
- val body1 = typed(tree.body, pt1)
1555
+ if ! isFullyDefined(pt, ForceDegree .all) then
1556
+ return errorTree(tree, i " expected type of $tree is not fully defined " )
1557
+ val body1 = typed(tree.body, pt)
1557
1558
body1 match {
1558
1559
case UnApply (fn, Nil , arg :: Nil )
1559
1560
if fn.symbol.exists && fn.symbol.owner == defn.ClassTagClass && ! body1.tpe.isError =>
@@ -1573,21 +1574,21 @@ class Typer extends Namer
1573
1574
// for a singleton pattern like `x @ Nil`, `x` should get the type from the scrutinee
1574
1575
// see tests/neg/i3200b.scala and SI-1503
1575
1576
val symTp =
1576
- if body1.tpe.isInstanceOf [TermRef ] then pt1
1577
+ if body1.tpe.isInstanceOf [TermRef ] then pt
1577
1578
else if isWildcardStarArg(body1)
1578
- || pt1 == defn.ImplicitScrutineeTypeRef
1579
+ || pt == defn.ImplicitScrutineeTypeRef
1579
1580
|| body1.tpe <:< pt // There is some strange interaction with gadt matching.
1580
1581
// and implicit scopes.
1581
1582
// run/t2755.scala fails to compile if this subtype test is omitted
1582
- // and the else clause is changed to `body1.tpe & pt1 `. What
1583
+ // and the else clause is changed to `body1.tpe & pt `. What
1583
1584
// happens is that we get either an Array[Float] or an Array[T]
1584
1585
// where T is GADT constrained to := Float. But the case body
1585
1586
// compiles only if the bound variable is Array[Float]. If
1586
1587
// it is Array[T] we get an implicit not found. To avoid fragility
1587
1588
// wrt to operand order for `&`, we include the explicit subtype test here.
1588
1589
// See also #5649.
1589
1590
then body1.tpe
1590
- else pt1 & body1.tpe
1591
+ else pt & body1.tpe
1591
1592
val sym = ctx.newPatternBoundSymbol(name, symTp, tree.span)
1592
1593
if (pt == defn.ImplicitScrutineeTypeRef || tree.mods.is(Given )) sym.setFlag(Given )
1593
1594
if (ctx.mode.is(Mode .InPatternAlternative ))
0 commit comments