Skip to content

Commit ffcc27b

Browse files
committed
Merge pull request #1064 from dotty-staging/fix-#1044-take-3
Third try for a fix for #1044: handle TypevarsMissContext mode in wildApprox
2 parents 2c08c72 + 534e4ad commit ffcc27b

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ object Implicits {
5252
mt.paramTypes.length != 1 ||
5353
!(argType relaxed_<:< mt.paramTypes.head)(ctx.fresh.setExploreTyperState)
5454
case poly: PolyType =>
55+
// We do not need to call ProtoTypes#constrained on `poly` because
56+
// `refMatches` is always called with mode TypevarsMissContext enabled.
5557
poly.resultType match {
5658
case mt: MethodType =>
5759
mt.isImplicit ||

src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,15 @@ object ProtoTypes {
391391
case tp: TypeAlias => // default case, inlined for speed
392392
tp.derivedTypeAlias(wildApprox(tp.alias, theMap))
393393
case tp @ PolyParam(poly, pnum) =>
394-
ctx.typerState.constraint.entry(tp) match {
395-
case bounds: TypeBounds => wildApprox(WildcardType(bounds))
396-
case NoType => WildcardType(wildApprox(poly.paramBounds(pnum)).bounds)
397-
case inst => wildApprox(inst)
398-
}
394+
def unconstrainedApprox = WildcardType(wildApprox(poly.paramBounds(pnum)).bounds)
395+
if (ctx.mode.is(Mode.TypevarsMissContext))
396+
unconstrainedApprox
397+
else
398+
ctx.typerState.constraint.entry(tp) match {
399+
case bounds: TypeBounds => wildApprox(WildcardType(bounds))
400+
case NoType => unconstrainedApprox
401+
case inst => wildApprox(inst)
402+
}
399403
case MethodParam(mt, pnum) =>
400404
WildcardType(TypeBounds.upper(wildApprox(mt.paramTypes(pnum))))
401405
case tp: TypeVar =>

tests/pos/i1044.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
val x = ???.getClass.getMethods.head.getParameterTypes.mkString(",")
3+
}

0 commit comments

Comments
 (0)