Skip to content

Commit 0e65cb7

Browse files
committed
bugfix: Adjust code after cherry picking
1 parent 6d2d490 commit 0e65cb7

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

presentation-compiler/src/main/dotty/tools/pc/InferredMethodProvider.scala

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ final class InferredMethodProvider(
101101
.mkString(", ")
102102

103103
def printSignature(
104-
methodName: Name,
105-
params: List[List[Type]],
104+
methodName: Name,
105+
params: List[List[Type]],
106106
retTypeOpt: Option[Type]
107107
): String =
108108
val retTypeString = retTypeOpt match
@@ -129,7 +129,7 @@ final class InferredMethodProvider(
129129
if pos > 0 then
130130
val isSpace = text(pos) == ' '
131131
val isTab = text(pos) == '\t'
132-
val indent = countIndent(params.text(), pos, 0)
132+
val indent = countIndent(params.text().nn, pos, 0)
133133

134134
if isSpace then " " * indent else if isTab then "\t" * indent else ""
135135
else ""
@@ -145,8 +145,8 @@ final class InferredMethodProvider(
145145
/**
146146
* Returns the position to insert the method signature for a container.
147147
* If the container has an empty body, the position is the end of the container.
148-
* If the container has a non-empty body, the position is the end of the last element in the body.
149-
*
148+
* If the container has a non-empty body, the position is the end of the last element in the body.
149+
*
150150
* @param container the container to insert the method signature for
151151
* @return the position to insert the method signature for the container and a boolean indicating if the container has an empty body
152152
*/
@@ -170,9 +170,9 @@ final class InferredMethodProvider(
170170

171171
/**
172172
* Extracts type information for a specific parameter in a method signature.
173-
* If the parameter is a function type, extracts both the function's argument types
173+
* If the parameter is a function type, extracts both the function's argument types
174174
* and return type. Otherwise, extracts just the parameter type.
175-
*
175+
*
176176
* @param methodType the method type to analyze
177177
* @param argIndex the index of the parameter to extract information for
178178
* @return a tuple of (argument types, return type) where:
@@ -192,10 +192,10 @@ final class InferredMethodProvider(
192192
else
193193
(None, Some(m.paramInfos(argIndex)))
194194
case _ => (None, None)
195-
195+
196196
def signatureEdits(signature: String): List[TextEdit] =
197197
val pos = insertPosition()
198-
val indent = indentation(params.text(), pos.start - 1)
198+
val indent = indentation(params.text().nn, pos.start - 1)
199199
val lspPos = pos.toLsp
200200
lspPos.setEnd(lspPos.getStart())
201201

@@ -211,7 +211,7 @@ final class InferredMethodProvider(
211211
case Some((pos, hasEmptyBody)) =>
212212
val lspPos = pos.toLsp
213213
lspPos.setStart(lspPos.getEnd())
214-
val indent = indentation(params.text(), pos.start - 1)
214+
val indent = indentation(params.text().nn, pos.start - 1)
215215

216216
if hasEmptyBody then
217217
List(
@@ -234,17 +234,17 @@ final class InferredMethodProvider(
234234
* outerArgs
235235
* ---------------------------
236236
* method(..., errorMethod(args), ...)
237-
*
237+
*
238238
*/
239-
case (id @ Ident(errorMethod)) ::
240-
(apply @ Apply(func, args)) ::
241-
Apply(method, outerArgs) ::
239+
case (id @ Ident(errorMethod)) ::
240+
(apply @ Apply(func, args)) ::
241+
Apply(method, outerArgs) ::
242242
_ if id.symbol == NoSymbol && func == id && method != apply =>
243-
243+
244244
val argTypes = args.map(_.typeOpt.widenDealias)
245245

246246
val argIndex = outerArgs.indexOf(apply)
247-
val (allArgTypes, retTypeOpt) =
247+
val (allArgTypes, retTypeOpt) =
248248
extractParameterTypeInfo(method.tpe.widenDealias, argIndex) match
249249
case (Some(argTypes2), retTypeOpt) => (List(argTypes, argTypes2), retTypeOpt)
250250
case (None, retTypeOpt) => (List(argTypes), retTypeOpt)
@@ -257,12 +257,12 @@ final class InferredMethodProvider(
257257
* outerArgs
258258
* ---------------------
259259
* method(..., errorMethod, ...)
260-
*
260+
*
261261
*/
262-
case (id @ Ident(errorMethod)) ::
263-
Apply(method, outerArgs) ::
262+
case (id @ Ident(errorMethod)) ::
263+
Apply(method, outerArgs) ::
264264
_ if id.symbol == NoSymbol && method != id =>
265-
265+
266266
val argIndex = outerArgs.indexOf(id)
267267

268268
val (argTypes, retTypeOpt) = extractParameterTypeInfo(method.tpe.widenDealias, argIndex)
@@ -272,20 +272,20 @@ final class InferredMethodProvider(
272272
case None => Nil
273273

274274
val signature = printSignature(errorMethod, allArgTypes, retTypeOpt)
275-
275+
276276
signatureEdits(signature)
277277

278278
/**
279279
* tpt body
280280
* ----------- ----------------
281281
* val value: DefinedType = errorMethod(args)
282-
*
282+
*
283283
*/
284-
case (id @ Ident(errorMethod)) ::
285-
(apply @ Apply(func, args)) ::
286-
ValDef(_, tpt, body) ::
284+
case (id @ Ident(errorMethod)) ::
285+
(apply @ Apply(func, args)) ::
286+
ValDef(_, tpt, body) ::
287287
_ if id.symbol == NoSymbol && func == id && apply == body =>
288-
288+
289289
val retType = tpt.tpe.widenDealias
290290
val argTypes = args.map(_.typeOpt.widenDealias)
291291

@@ -296,24 +296,24 @@ final class InferredMethodProvider(
296296
* tpt body
297297
* ----------- -----------
298298
* val value: DefinedType = errorMethod
299-
*
299+
*
300300
*/
301-
case (id @ Ident(errorMethod)) ::
302-
ValDef(_, tpt, body) ::
301+
case (id @ Ident(errorMethod)) ::
302+
ValDef(_, tpt, body) ::
303303
_ if id.symbol == NoSymbol && id == body =>
304-
304+
305305
val retType = tpt.tpe.widenDealias
306306

307307
val signature = printSignature(errorMethod, Nil, Some(retType))
308308
signatureEdits(signature)
309309

310310
/**
311-
*
311+
*
312312
* errorMethod(args)
313-
*
313+
*
314314
*/
315-
case (id @ Ident(errorMethod)) ::
316-
(apply @ Apply(func, args)) ::
315+
case (id @ Ident(errorMethod)) ::
316+
(apply @ Apply(func, args)) ::
317317
_ if id.symbol == NoSymbol && func == id =>
318318

319319
val argTypes = args.map(_.typeOpt.widenDealias)
@@ -322,37 +322,37 @@ final class InferredMethodProvider(
322322
signatureEdits(signature)
323323

324324
/**
325-
*
325+
*
326326
* errorMethod
327-
*
327+
*
328328
*/
329-
case (id @ Ident(errorMethod)) ::
329+
case (id @ Ident(errorMethod)) ::
330330
_ if id.symbol == NoSymbol =>
331331

332332
val signature = printSignature(errorMethod, Nil, None)
333333
signatureEdits(signature)
334334

335335
/**
336-
*
336+
*
337337
* container.errorMethod(args)
338-
*
338+
*
339339
*/
340-
case (select @ Select(container, errorMethod)) ::
341-
(apply @ Apply(func, args)) ::
340+
case (select @ Select(container, errorMethod)) ::
341+
(apply @ Apply(func, args)) ::
342342
_ if select.symbol == NoSymbol && func == select =>
343-
343+
344344
val argTypes = args.map(_.typeOpt.widenDealias)
345345
val signature = printSignature(errorMethod, List(argTypes), None)
346346
signatureEditsForContainer(signature, container)
347347

348348
/**
349-
*
349+
*
350350
* container.errorMethod
351-
*
351+
*
352352
*/
353-
case (select @ Select(container, errorMethod)) ::
353+
case (select @ Select(container, errorMethod)) ::
354354
_ if select.symbol == NoSymbol =>
355-
355+
356356
val signature = printSignature(errorMethod, Nil, None)
357357
signatureEditsForContainer(signature, container)
358358

0 commit comments

Comments
 (0)