@@ -45,7 +45,14 @@ object ProtoTypes {
4545 }
4646 if (keepConstraint)
4747 tp.widenSingleton match {
48- case poly : PolyType => normalizedCompatible(tp, pt, keepConstraint = false )
48+ case poly : PolyType =>
49+ // We can't keep the constraint in this case, since we have to add type parameters
50+ // to it, but there's no place to associate them with type variables.
51+ // So we'd get a "inconsistent: no typevars were added to committable constraint"
52+ // assertion failure in `constrained`. To do better, we'd have to change the
53+ // constraint handling architecture so that some type parameters are committable
54+ // and others are not. But that's a whole different ballgame.
55+ normalizedCompatible(tp, pt, keepConstraint = false )
4956 case _ => testCompat
5057 }
5158 else ctx.test(implicit ctx => testCompat)
@@ -246,6 +253,8 @@ object ProtoTypes {
246253 def isMatchedBy (tp : Type , keepConstraint : Boolean )(implicit ctx : Context ): Boolean = {
247254 val args = unforcedTypedArgs
248255 def isPoly (tree : Tree ) = tree.tpe.widenSingleton.isInstanceOf [PolyType ]
256+ // See remark in normalizedCompatible for why we can't keep the constraint
257+ // if one of the arguments has a PolyType.
249258 typer.isApplicable(tp, Nil , args, resultType, keepConstraint && ! args.exists(isPoly))
250259 }
251260
@@ -308,7 +317,7 @@ object ProtoTypes {
308317 if (state.typedArgs.size == args.length) state.typedArgs
309318 else {
310319 val args1 = args.mapconserve(cacheTypedArg(_, typer.typed(_), force))
311- if (! args1.contains(WildcardType )) state.typedArgs = args1
320+ if (force || ! args1.contains(WildcardType )) state.typedArgs = args1
312321 args1
313322 }
314323
0 commit comments