Skip to content

Third try for a fix for #1044: handle TypevarsMissContext mode in wildApprox #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ object Implicits {
mt.paramTypes.length != 1 ||
!(argType relaxed_<:< mt.paramTypes.head)(ctx.fresh.setExploreTyperState)
case poly: PolyType =>
// We do not need to call ProtoTypes#constrained on `poly` because
// `refMatches` is always called with mode TypevarsMissContext enabled.
poly.resultType match {
case mt: MethodType =>
mt.isImplicit ||
Expand Down
14 changes: 9 additions & 5 deletions src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,15 @@ object ProtoTypes {
case tp: TypeAlias => // default case, inlined for speed
tp.derivedTypeAlias(wildApprox(tp.alias, theMap))
case tp @ PolyParam(poly, pnum) =>
ctx.typerState.constraint.entry(tp) match {
case bounds: TypeBounds => wildApprox(WildcardType(bounds))
case NoType => WildcardType(wildApprox(poly.paramBounds(pnum)).bounds)
case inst => wildApprox(inst)
}
def unconstrainedApprox = WildcardType(wildApprox(poly.paramBounds(pnum)).bounds)
if (ctx.mode.is(Mode.TypevarsMissContext))
unconstrainedApprox
else
ctx.typerState.constraint.entry(tp) match {
case bounds: TypeBounds => wildApprox(WildcardType(bounds))
case NoType => unconstrainedApprox
case inst => wildApprox(inst)
}
case MethodParam(mt, pnum) =>
WildcardType(TypeBounds.upper(wildApprox(mt.paramTypes(pnum))))
case tp: TypeVar =>
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i1044.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test {
val x = ???.getClass.getMethods.head.getParameterTypes.mkString(",")
}