@@ -28,43 +28,17 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
2828 private type SpecialHandlers = List [(ClassSymbol , SpecialHandler )]
2929
3030 val synthesizedClassTag : SpecialHandler = (formal, span) =>
31- def instArg (tp : Type ): Type = tp.dealias match
31+ def instArg (tp : Type ): Type = tp.stripTypeVar match
3232 // Special case to avoid instantiating `Int & S` to `Int & Nothing` in
3333 // i16328.scala. The intersection comes from an earlier instantiation
3434 // to an upper bound.
3535 // The dual situation with unions is harder to trigger because lower
3636 // bounds are usually widened during instantiation.
3737 case tp : AndOrType if tp.tp1 =:= tp.tp2 =>
3838 instArg(tp.tp1)
39- case tvar : TypeVar if ctx.typerState.constraint.contains(tvar) =>
40- // If tvar has a lower or upper bound:
41- // 1. If the bound is not another type variable, use this as approximation.
42- // 2. Otherwise, if the type can be forced to be fully defined, use that type
43- // as approximation.
44- // 3. Otherwise leave argument uninstantiated.
45- // The reason for (2) is that we observed complicated constraints in i23611.scala
46- // that get better types if a fully defined type is computed than if several type
47- // variables are approximated incrementally. This is a minimization of some ZIO code.
48- // So in order to keep backwards compatibility (where before we _only_ did 2) we
49- // add that special case.
50- def isGroundConstr (tp : Type ): Boolean = tp.dealias match
51- case tvar : TypeVar if ctx.typerState.constraint.contains(tvar) => false
52- case pref : TypeParamRef if ctx.typerState.constraint.contains(pref) => false
53- case tp : AndOrType => isGroundConstr(tp.tp1) && isGroundConstr(tp.tp2)
54- case _ => true
55- instArg(
56- if tvar.hasLowerBound then
57- if isGroundConstr(fullLowerBound(tvar.origin)) then tvar.instantiate(fromBelow = true )
58- else if isFullyDefined(tp, ForceDegree .all) then tp
59- else NoType
60- else if tvar.hasUpperBound then
61- if isGroundConstr(fullUpperBound(tvar.origin)) then tvar.instantiate(fromBelow = false )
62- else if isFullyDefined(tp, ForceDegree .all) then tp
63- else NoType
64- else
65- NoType )
6639 case _ =>
67- tp
40+ if isFullyDefined(tp, ForceDegree .all) then tp
41+ else NoType // this happens in tests/neg/i15372.scala
6842
6943 val tag = formal.argInfos match
7044 case arg :: Nil =>
0 commit comments