File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
309309 toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
310310 case tp @ FunProto (args, resultType) =>
311311 " [applied to ("
312- ~ keywordText(" using " ).provided(tp.isContextualMethod )
312+ ~ keywordText(" using " ).provided(tp.applyKind == ApplyKind . Using )
313313 ~ argsTreeText(args)
314314 ~ " ) returning "
315315 ~ toText(resultType)
Original file line number Diff line number Diff line change @@ -106,12 +106,14 @@ trait Migrations:
106106 && isContextBoundParams
107107 && pt.applyKind != ApplyKind .Using
108108 then
109- def rewriteMsg = Message .rewriteNotice(" This code" , mversion.patchFrom)
109+ def rewriteMsg =
110+ if pt.args.isEmpty then " "
111+ else Message .rewriteNotice(" This code" , mversion.patchFrom)
110112 report.errorOrMigrationWarning(
111113 em """ Context bounds will map to context parameters.
112114 |A `using` clause is needed to pass explicit arguments to them. $rewriteMsg""" ,
113115 tree.srcPos, mversion)
114- if mversion.needsPatch then
116+ if mversion.needsPatch && pt.args.nonEmpty then
115117 patch(Span (pt.args.head.span.start), " using " )
116118 end contextBoundParams
117119
Original file line number Diff line number Diff line change @@ -3906,7 +3906,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
39063906 if (arg.tpe.isError) Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
39073907 }
39083908 val app = cpy.Apply (tree)(untpd.TypedSplice (tree), namedArgs)
3909- if (wtp.isContextualMethod) app.setApplyKind(ApplyKind .Using )
3909+ val needsUsing = wtp.isContextualMethod || wtp.match
3910+ case MethodType (ContextBoundParamName (_) :: _) => sourceVersion.isAtLeast(`3.4`)
3911+ case _ => false
3912+ if needsUsing then app.setApplyKind(ApplyKind .Using )
39103913 typr.println(i " try with default implicit args $app" )
39113914 typed(app, pt, locked)
39123915 else issueErrors()
Original file line number Diff line number Diff line change 1+ //> using options " -source 3.4-migration" ,
2+
3+ trait Reader [T ]
4+ def read [T : Reader ](s : String , trace : Boolean = false ): T = ???
5+
6+ def Test =
7+ read[Object ](" " ) // error
8+ read[Object ](" " )() // error
You can’t perform that action at this time.
0 commit comments