Skip to content

Fix #6503: Handle dependent refinements #7943

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 9, 2020
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ object ErrorReporting {
*/
def userDefinedErrorString(raw: String, paramNames: List[String], args: List[Type]): String = {
def translate(name: String): Option[String] = {
assert(paramNames.length == args.length)
val idx = paramNames.indexOf(name)
if (idx >= 0) Some(quoteReplacement(ex"${args(idx)}")) else None
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ trait Implicits { self: Typer =>
err.userDefinedErrorString(
raw,
pt.typeSymbol.typeParams.map(_.name.unexpandedName.toString),
pt.widenExpr.argInfos))
pt.widenExpr.dropDependentRefinement.argInfos))

def hiddenImplicitsAddendum: String =

Expand Down
37 changes: 37 additions & 0 deletions tests/neg/i6503.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
trait MapImpl {
type Key
type Value
type Map
val lookup: Map => Key => Value
}
import scala.collection.immutable.HashMap

class HashMapImpl[K, V] extends MapImpl {
type Key = K
type Value = V
type Map = HashMap[K, V]
val lookup: Map => Key => Value = m => k => m(k)
}

object Foo {
val Server0:
(mImpl: MapImpl) => mImpl.Map => mImpl.Key => mImpl.Value
= mImpl => mImpl.lookup
val Client:
(server: (mImpl: MapImpl { type Key = String; type Value = Int}) => mImpl.Map => String => Int) => Int =
server => server(HashMapImpl[String, Int])(HashMap())("test lookup key")
val Client1:
(server: (mImpl: MapImpl { type Key = String; type Value = Int}) => mImpl.Map => String => Int) => Int =
server => server(??? : (HashMapImpl[String, Int]))(???)("test lookup key")
val Client2:
(server: (mImpl: MapImpl { type Key = String; type Value = Int}) => mImpl.Map => String => Int) => Int =
server => server(???)(???)("test lookup key")
val Server1: (mImpl: MapImpl {type Key = String; type Value = Int}) => mImpl.Map => String => Int =
mImpl => Server0(mImpl)
implicitly[(mImpl: MapImpl {type Key = String; type Value = Int}) => mImpl.Map => String => Int <:< (mImpl: MapImpl) => mImpl.Map => mImpl.Key => mImpl.Value] // error
implicitly[(mImpl: MapImpl {type Key = String; type Value = Int}) => mImpl.Map => mImpl.Key => mImpl.Value <:< (mImpl: MapImpl) => mImpl.Map => mImpl.Key => mImpl.Value] // error

val Result1: Int = Client(Server0) // error
val Result2: Int = Client(Server1)
val Result3: Int = Client(mImpl => Server0(mImpl))
}