File tree Expand file tree Collapse file tree 2 files changed +66
-4
lines changed
test/dotty/tools/pc/tests/edit Expand file tree Collapse file tree 2 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -182,8 +182,7 @@ final class InferredTypeProvider(
182
182
typeNameEdit ::: imports
183
183
184
184
rhs match
185
- case t : Tree [? ]
186
- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
185
+ case t : Tree [? ] if ! tpt.sourcePos.span.isZeroExtent =>
187
186
inferredTypeEdits(
188
187
Some (
189
188
AdjustTypeOpts (
@@ -223,8 +222,7 @@ final class InferredTypeProvider(
223
222
while i >= 0 && sourceText(i) != ':' do i -= 1
224
223
i
225
224
rhs match
226
- case t : Tree [? ]
227
- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
225
+ case t : Tree [? ] if ! tpt.sourcePos.span.isZeroExtent =>
228
226
inferredTypeEdits(
229
227
Some (
230
228
AdjustTypeOpts (
Original file line number Diff line number Diff line change @@ -1055,6 +1055,70 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
1055
1055
|""" .stripMargin
1056
1056
)
1057
1057
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
+
1058
1122
def checkEdit (
1059
1123
original : String ,
1060
1124
expected : String
You can’t perform that action at this time.
0 commit comments