Skip to content

Fix #2979: Allow for instantiated params when approximating #3826

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
Jan 15, 2018
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
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ trait ConstraintHandling {
}
}
}
if (constraint.contains(param)) {
val bound = if (fromBelow) constraint.fullLowerBound(param) else constraint.fullUpperBound(param)
val inst = avoidParam(bound)
typr.println(s"approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}")
inst
}
else {
assert(ctx.mode.is(Mode.Interactive))
UnspecifiedErrorType
constraint.entry(param) match {
case _: TypeBounds =>
val bound = if (fromBelow) constraint.fullLowerBound(param) else constraint.fullUpperBound(param)
val inst = avoidParam(bound)
typr.println(s"approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}")
inst
case inst =>
assert(inst.exists, i"param = $param\n constraint = $constraint")
inst
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i2979.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Main {
Map(
"a" -> Unknown(), // error
"b" -> Unknown() // error
)
}