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 @@ -183,8 +183,7 @@ final class InferredTypeProvider(
183
183
typeNameEdit ::: imports
184
184
185
185
rhs match
186
- case t : Tree [? ]
187
- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
186
+ case t : Tree [? ] if ! tpt.sourcePos.span.isZeroExtent =>
188
187
inferredTypeEdits(
189
188
Some (
190
189
AdjustTypeOpts (
@@ -224,8 +223,7 @@ final class InferredTypeProvider(
224
223
while i >= 0 && sourceText(i) != ':' do i -= 1
225
224
i
226
225
rhs match
227
- case t : Tree [? ]
228
- if t.typeOpt.isErroneous && retryType && ! tpt.sourcePos.span.isZeroExtent =>
226
+ case t : Tree [? ] if ! tpt.sourcePos.span.isZeroExtent =>
229
227
inferredTypeEdits(
230
228
Some (
231
229
AdjustTypeOpts (
Original file line number Diff line number Diff line change @@ -1035,6 +1035,70 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
1035
1035
|""" .stripMargin
1036
1036
)
1037
1037
1038
+ @ Test def `Adjust type for val` =
1039
+ checkEdit(
1040
+ """ |object A{
1041
+ | val <<alpha>>:String = 123
1042
+ |}""" .stripMargin,
1043
+
1044
+ """ |object A{
1045
+ | val alpha: Int = 123
1046
+ |}""" .stripMargin,
1047
+ )
1048
+
1049
+ @ Test def `Adjust type for val2` =
1050
+ checkEdit(
1051
+ """ |object A{
1052
+ | val <<alpha>>:Int = 123
1053
+ |}""" .stripMargin,
1054
+ """ |object A{
1055
+ | val alpha: Int = 123
1056
+ |}""" .stripMargin,
1057
+ )
1058
+
1059
+ @ Test def `Adjust type for val3` =
1060
+ checkEdit(
1061
+ """ |object A{
1062
+ | val <<alpha>>: Int = 123
1063
+ |}""" .stripMargin,
1064
+ """ |object A{
1065
+ | val alpha: Int = 123
1066
+ |}""" .stripMargin,
1067
+ )
1068
+
1069
+ @ Test def `Adjust type for def` =
1070
+ checkEdit(
1071
+ """ |object A{
1072
+ | def <<alpha>>:String = 123
1073
+ |}""" .stripMargin,
1074
+
1075
+ """ |object A{
1076
+ | def alpha: Int = 123
1077
+ |}""" .stripMargin,
1078
+ )
1079
+
1080
+ @ Test def `Adjust type for def2` =
1081
+ checkEdit(
1082
+ """ |object A{
1083
+ | def <<alpha>>:Int = 123
1084
+ |}""" .stripMargin,
1085
+ """ |object A{
1086
+ | def alpha: Int = 123
1087
+ |}""" .stripMargin,
1088
+ )
1089
+
1090
+
1091
+ @ Test def `Adjust type for def3` =
1092
+ checkEdit(
1093
+ """ |object A{
1094
+ | def <<alpha>>: Int = 123
1095
+ |}""" .stripMargin,
1096
+ """ |object A{
1097
+ | def alpha: Int = 123
1098
+ |}""" .stripMargin,
1099
+ )
1100
+
1101
+
1038
1102
def checkEdit (
1039
1103
original : String ,
1040
1104
expected : String
You can’t perform that action at this time.
0 commit comments