File tree 3 files changed +24
-3
lines changed
compiler/src/dotty/tools/dotc/typer 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,6 @@ object ErrorReporting {
240
240
def err (using Context ): Errors = new Errors
241
241
}
242
242
243
-
244
243
class ImplicitSearchError (
245
244
arg : tpd.Tree ,
246
245
pt : Type ,
@@ -249,6 +248,7 @@ class ImplicitSearchError(
249
248
ignoredInstanceNormalImport : => Option [SearchSuccess ],
250
249
importSuggestionAddendum : => String
251
250
)(using ctx : Context ) {
251
+
252
252
def missingArgMsg = arg.tpe match {
253
253
case ambi : AmbiguousImplicits =>
254
254
(ambi.alt1, ambi.alt2) match {
Original file line number Diff line number Diff line change @@ -1050,8 +1050,13 @@ trait Implicits:
1050
1050
val generated : Tree = tpd.ref(ref).withSpan(span.startPos)
1051
1051
val locked = ctx.typerState.ownedVars
1052
1052
val adapted =
1053
- if (argument.isEmpty)
1054
- adapt(generated, pt.widenExpr, locked)
1053
+ if argument.isEmpty then
1054
+ if defn.isContextFunctionType(pt) then
1055
+ // need to go through typed, to build the context closure
1056
+ typed(untpd.TypedSplice (generated), pt, locked)
1057
+ else
1058
+ // otherwise we can skip typing and go directly to adapt
1059
+ adapt(generated, pt.widenExpr, locked)
1055
1060
else {
1056
1061
def untpdGenerated = untpd.TypedSplice (generated)
1057
1062
def producesConversion (info : Type ): Boolean = info match
Original file line number Diff line number Diff line change
1
+ class Dummy
2
+ given Dummy = ???
3
+ trait Foo
4
+ given foo : Foo = ???
5
+ trait Bar
6
+ given bar (using Dummy ): Bar = ???
7
+
8
+ object Test :
9
+ summon[Dummy ?=> Foo ] // was error
10
+ summon[Dummy ?=> Foo ](using foo) // works
11
+ summon[Dummy ?=> Foo ](using (_ : Dummy ) ?=> foo) // works
12
+ summon[Dummy ?=> Bar ]
13
+ summon[Dummy ?=> Bar ](using bar) // works
14
+ summon[Dummy ?=> Bar ](using (_ : Dummy ) ?=> bar) // works
15
+
16
+
You can’t perform that action at this time.
0 commit comments