Преглед изворни кода

recurse into singularly constrained monos for field collection

closes #11918
Simon Krajewski пре 6 месеци
родитељ
комит
366ad7c776
2 измењених фајлова са 20 додато и 0 уклоњено
  1. 2 0
      src/context/display/displayFields.ml
  2. 18 0
      tests/display/src/cases/Issue11918.hx

+ 2 - 0
src/context/display/displayFields.ml

@@ -169,6 +169,8 @@ let collect ctx e_ast e dk with_type p =
 					end
 					end
 				end else
 				end else
 					loop items (mk_anon ~fields (ref Closed))
 					loop items (mk_anon ~fields (ref Closed))
+			| CTypes [(t,_)] ->
+				loop items t
 			| CTypes tl ->
 			| CTypes tl ->
 				items
 				items
 			| CUnknown ->
 			| CUnknown ->

+ 18 - 0
tests/display/src/cases/Issue11918.hx

@@ -0,0 +1,18 @@
+package cases;
+
+class Issue11918 extends DisplayTestCase {
+	/**
+		function main() {
+			final foo = get();
+			// foo is mono, no completion for String methods
+			foo.{-1-}
+		}
+
+		function get<T:String>():T {
+			return cast "";
+		}
+	**/
+	function test1() {
+		eq(true, hasField(fields(pos(1)), "length", "Int"));
+	}
+}