瀏覽代碼

[java][cs] check unify errors both directions before emiting "invalid expression" warning
#8589

Aleksandr Kuzmenko 6 年之前
父節點
當前提交
9d15dd98ae
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/codegen/gencommon/castDetect.ml

+ 6 - 1
src/codegen/gencommon/castDetect.ml

@@ -709,7 +709,12 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 			with
 				| Unify_error el ->
 						(match el with
-						| [Cannot_unify (TAbstract(a,params), b)] ->
+						(*
+							Don't emit a warning for abstracts if underlying type is the same as the second type.
+							This situation is caused by `Normalize.filter_param` not "unpacking" abstracts.
+						*)
+						| [Cannot_unify (TAbstract(a,params), b)]
+						| [Cannot_unify (b, TAbstract(a,params))] ->
 							let a = apply_params a.a_params params a.a_this in
 							if not (shallow_eq a b) then
 								gen.gcon.warning ("This expression may be invalid") pos