File tree 4 files changed +17
-4
lines changed
compiler/src/dotty/tools/dotc
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) {
309
309
toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
310
310
case tp @ FunProto (args, resultType) =>
311
311
" [applied to ("
312
- ~ keywordText(" using " ).provided(tp.isContextualMethod )
312
+ ~ keywordText(" using " ).provided(tp.applyKind == ApplyKind . Using )
313
313
~ argsTreeText(args)
314
314
~ " ) returning "
315
315
~ toText(resultType)
Original file line number Diff line number Diff line change @@ -106,12 +106,14 @@ trait Migrations:
106
106
&& isContextBoundParams
107
107
&& pt.applyKind != ApplyKind .Using
108
108
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)
110
112
report.errorOrMigrationWarning(
111
113
em """ Context bounds will map to context parameters.
112
114
|A `using` clause is needed to pass explicit arguments to them. $rewriteMsg""" ,
113
115
tree.srcPos, mversion)
114
- if mversion.needsPatch then
116
+ if mversion.needsPatch && pt.args.nonEmpty then
115
117
patch(Span (pt.args.head.span.start), " using " )
116
118
end contextBoundParams
117
119
Original file line number Diff line number Diff line change @@ -3906,7 +3906,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3906
3906
if (arg.tpe.isError) Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
3907
3907
}
3908
3908
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 )
3910
3913
typr.println(i " try with default implicit args $app" )
3911
3914
typed(app, pt, locked)
3912
3915
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