File tree 5 files changed +42
-2
lines changed
compiler/src/dotty/tools/dotc/typer
5 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -826,7 +826,7 @@ trait Implicits:
826
826
&& ! to.isError
827
827
&& ! ctx.isAfterTyper
828
828
&& ctx.mode.is(Mode .ImplicitsEnabled )
829
- && from.widen. isValueType
829
+ && from.isValueType
830
830
&& ( from.isValueSubType(to)
831
831
|| inferView(dummyTreeOfType(from), to)
832
832
(using ctx.fresh.addMode(Mode .ImplicitExploration ).setExploreTyperState()).isSuccess
@@ -958,7 +958,7 @@ trait Implicits:
958
958
.filter { imp =>
959
959
! isImplicitDefConversion(imp.underlying)
960
960
&& imp.symbol != defn.Predef_conforms
961
- && viewExists(imp, fail.expectedType)
961
+ && viewExists(imp.underlying.resultType , fail.expectedType)
962
962
}
963
963
else
964
964
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 foo2[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