compiler: Added prefixed and suffixed `String` support
[nit.git] / src / modelize / modelize_property.nit
index 23ac65f..df8f8bd 100644 (file)
@@ -1406,7 +1406,16 @@ redef class AAttrPropdef
                                        var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "String")
                                        if cla != null then mtype = cla.mclass_type
                                else if nexpr isa AStringFormExpr then
-                                       var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "String")
+                                       var cla: nullable MClass
+                                       if nexpr.is_bytestring then
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Bytes")
+                                       else if nexpr.is_re then
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Regex")
+                                       else if nexpr.is_string then
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "String")
+                                       else
+                                               abort
+                                       end
                                        if cla != null then mtype = cla.mclass_type
                                else
                                        modelbuilder.error(self, "Error: untyped attribute `{mreadpropdef}`. Implicit typing allowed only for literals and new.")