File tree Expand file tree Collapse file tree 5 files changed +45
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -850,7 +850,7 @@ trait Implicits:
850850 && ! to.isError
851851 && ! ctx.isAfterTyper
852852 && ctx.mode.is(Mode .ImplicitsEnabled )
853- && from.widen. isValueType
853+ && from.isValueType
854854 && ( from.isValueSubType(to)
855855 || inferView(dummyTreeOfType(from), to)
856856 (using ctx.fresh.addMode(Mode .ImplicitExploration ).setExploreTyperState()).isSuccess
@@ -982,7 +982,10 @@ trait Implicits:
982982 .filter { imp =>
983983 ! isImplicitDefConversion(imp.underlying)
984984 && imp.symbol != defn.Predef_conforms
985- && viewExists(imp, fail.expectedType)
985+ && viewExists(imp.underlying.match {
986+ case tp : TypeLambda => tp.resultType
987+ case tp => tp
988+ }, fail.expectedType)
986989 }
987990 else
988991 Nil
Original file line number Diff line number Diff line change 1+ -- [E172] Type Error: tests/neg/i16453b1.scala:11:19 -------------------------------------------------------------------
2+ 11 | val ko = get[Int] // error
3+ | ^
4+ |No given instance of type Ctx => Option[Int] was found for parameter fn of method get
5+ |
6+ |Note: implicit conversions are not automatically applied to arguments of using clauses. You will have to pass the argument explicitly.
7+ |The following implicits in scope can be implicitly converted to Ctx => Option[Int]:
8+ |- final lazy given val foo: Ctx => Int
Original file line number Diff line number Diff line change 1+ import scala .language .implicitConversions
2+
3+ sealed trait Ctx
4+ given ct [T ]: Conversion [Ctx => T , Ctx => Option [T ]] = fn => fn.andThen(Option .apply)
5+
6+ def get [T ](using fn : Ctx => Option [T ]): Option [T ] = ???
7+
8+ def Test = {
9+ given foo : (Ctx => Int ) = _ => 42
10+ val ok = get[Int ](using summon[Ctx => Int ])
11+ val ko = get[Int ] // error
12+ }
Original file line number Diff line number Diff line change 1+ -- [E172] Type Error: tests/neg/i16453b2.scala:11:19 -------------------------------------------------------------------
2+ 11 | val ko = get[Int] // error
3+ | ^
4+ |No given instance of type Ctx => Option[Int] was found for parameter fn of method get
5+ |
6+ |Note: implicit conversions are not automatically applied to arguments of using clauses. You will have to pass the argument explicitly.
7+ |The following implicits in scope can be implicitly converted to Ctx => Option[Int]:
8+ |- final given def foo[A]: Ctx => Int
Original file line number Diff line number Diff line change 1+ import scala .language .implicitConversions
2+
3+ sealed trait Ctx
4+ given ct [T ]: Conversion [Ctx => T , Ctx => Option [T ]] = fn => fn.andThen(Option .apply)
5+
6+ def get [T ](using fn : Ctx => Option [T ]): Option [T ] = ???
7+
8+ def Test = {
9+ given foo2 [A ]: (Ctx => Int ) = _ => 42
10+ val ok = get[Int ](using summon[Ctx => Int ])
11+ val ko = get[Int ] // error
12+ }
You can’t perform that action at this time.
0 commit comments