File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,6 @@ object ErrorReporting {
240240 def err (using Context ): Errors = new Errors
241241}
242242
243-
244243class ImplicitSearchError (
245244 arg : tpd.Tree ,
246245 pt : Type ,
@@ -249,6 +248,7 @@ class ImplicitSearchError(
249248 ignoredInstanceNormalImport : => Option [SearchSuccess ],
250249 importSuggestionAddendum : => String
251250)(using ctx : Context ) {
251+
252252 def missingArgMsg = arg.tpe match {
253253 case ambi : AmbiguousImplicits =>
254254 (ambi.alt1, ambi.alt2) match {
Original file line number Diff line number Diff line change @@ -1050,8 +1050,13 @@ trait Implicits:
10501050 val generated : Tree = tpd.ref(ref).withSpan(span.startPos)
10511051 val locked = ctx.typerState.ownedVars
10521052 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)
10551060 else {
10561061 def untpdGenerated = untpd.TypedSplice (generated)
10571062 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