File tree Expand file tree Collapse file tree 2 files changed +66
-2
lines changed
test/dotty/tools/pc/tests/edit Expand file tree Collapse file tree 2 files changed +66
-2
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ final class InferredTypeProvider(
183183
184184 rhs match
185185 case t : Tree [? ]
186- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
186+ if ! tpt.sourcePos.span.isZeroExtent =>
187187 inferredTypeEdits(
188188 Some (
189189 AdjustTypeOpts (
@@ -224,7 +224,7 @@ final class InferredTypeProvider(
224224 i
225225 rhs match
226226 case t : Tree [? ]
227- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
227+ if ! tpt.sourcePos.span.isZeroExtent =>
228228 inferredTypeEdits(
229229 Some (
230230 AdjustTypeOpts (
Original file line number Diff line number Diff line change @@ -1055,6 +1055,70 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
10551055 |""" .stripMargin
10561056 )
10571057
1058+ @ Test def `Adjust type for val` =
1059+ checkEdit(
1060+ """ |object A{
1061+ | val <<alpha>>:String = 123
1062+ |}""" .stripMargin,
1063+
1064+ """ |object A{
1065+ | val alpha: Int = 123
1066+ |}""" .stripMargin,
1067+ )
1068+
1069+ @ Test def `Adjust type for val2` =
1070+ checkEdit(
1071+ """ |object A{
1072+ | val <<alpha>>:Int = 123
1073+ |}""" .stripMargin,
1074+ """ |object A{
1075+ | val alpha: Int = 123
1076+ |}""" .stripMargin,
1077+ )
1078+
1079+ @ Test def `Adjust type for val3` =
1080+ checkEdit(
1081+ """ |object A{
1082+ | val <<alpha>>: Int = 123
1083+ |}""" .stripMargin,
1084+ """ |object A{
1085+ | val alpha: Int = 123
1086+ |}""" .stripMargin,
1087+ )
1088+
1089+ @ Test def `Adjust type for def` =
1090+ checkEdit(
1091+ """ |object A{
1092+ | def <<alpha>>:String = 123
1093+ |}""" .stripMargin,
1094+
1095+ """ |object A{
1096+ | def alpha: Int = 123
1097+ |}""" .stripMargin,
1098+ )
1099+
1100+ @ Test def `Adjust type for def2` =
1101+ checkEdit(
1102+ """ |object A{
1103+ | def <<alpha>>:Int = 123
1104+ |}""" .stripMargin,
1105+ """ |object A{
1106+ | def alpha: Int = 123
1107+ |}""" .stripMargin,
1108+ )
1109+
1110+
1111+ @ Test def `Adjust type for def3` =
1112+ checkEdit(
1113+ """ |object A{
1114+ | def <<alpha>>: Int = 123
1115+ |}""" .stripMargin,
1116+ """ |object A{
1117+ | def alpha: Int = 123
1118+ |}""" .stripMargin,
1119+ )
1120+
1121+
10581122 def checkEdit (
10591123 original : String ,
10601124 expected : String
You can’t perform that action at this time.
0 commit comments