diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala index f83159c69b6d..8ff7e0c26697 100644 --- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -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 } diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index ff83645aa476..329d5e97d2f3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -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 = diff --git a/tests/neg/i6503.scala b/tests/neg/i6503.scala new file mode 100644 index 000000000000..a670f2cee421 --- /dev/null +++ b/tests/neg/i6503.scala @@ -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)) +}