@@ -5731,6 +5731,82 @@ mod opt_tests {
57315731 "# ] ] ) ;
57325732 }
57335733
5734+ #[ test]
5735+ fn normal_class_type_inference ( ) {
5736+ eval ( "
5737+ class C; end
5738+ def test = C
5739+ test # Warm the constant cache
5740+ " ) ;
5741+ assert_optimized_method_hir ( "test" , expect ! [ [ r#"
5742+ fn test:
5743+ bb0(v0:BasicObject):
5744+ PatchPoint SingleRactorMode
5745+ PatchPoint StableConstantNames(0x1000, C)
5746+ v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5747+ Return v7
5748+ "# ] ] ) ;
5749+ }
5750+
5751+ #[ test]
5752+ fn core_classes_type_inference ( ) {
5753+ eval ( "
5754+ def test = [String, Class, BasicObject]
5755+ test # Warm the constant cache
5756+ " ) ;
5757+ assert_optimized_method_hir ( "test" , expect ! [ [ r#"
5758+ fn test:
5759+ bb0(v0:BasicObject):
5760+ PatchPoint SingleRactorMode
5761+ PatchPoint StableConstantNames(0x1000, String)
5762+ v13:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5763+ PatchPoint SingleRactorMode
5764+ PatchPoint StableConstantNames(0x1010, Class)
5765+ v16:ClassExact[VALUE(0x1018)] = Const Value(VALUE(0x1018))
5766+ PatchPoint SingleRactorMode
5767+ PatchPoint StableConstantNames(0x1020, BasicObject)
5768+ v19:ClassExact[VALUE(0x1028)] = Const Value(VALUE(0x1028))
5769+ v9:ArrayExact = NewArray v13, v16, v19
5770+ Return v9
5771+ "# ] ] ) ;
5772+ }
5773+
5774+ #[ test]
5775+ fn normal_module_instances_not_class_exact ( ) {
5776+ eval ( "
5777+ def test = [Enumerable, Kernel]
5778+ test # Warm the constant cache
5779+ " ) ;
5780+ assert_optimized_method_hir ( "test" , expect ! [ [ r#"
5781+ fn test:
5782+ bb0(v0:BasicObject):
5783+ PatchPoint SingleRactorMode
5784+ PatchPoint StableConstantNames(0x1000, Enumerable)
5785+ v11:BasicObject[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5786+ PatchPoint SingleRactorMode
5787+ PatchPoint StableConstantNames(0x1010, Kernel)
5788+ v14:BasicObject[VALUE(0x1018)] = Const Value(VALUE(0x1018))
5789+ v7:ArrayExact = NewArray v11, v14
5790+ Return v7
5791+ "# ] ] ) ;
5792+ }
5793+
5794+ #[ test]
5795+ fn core_module_constant_not_class_exact ( ) {
5796+ eval ( "
5797+ def test = Module
5798+ test # Warm the constant cache
5799+ " ) ;
5800+ assert_optimized_method_hir ( "test" , expect ! [ [ r#"
5801+ fn test:
5802+ bb0(v0:BasicObject):
5803+ PatchPoint SingleRactorMode
5804+ PatchPoint StableConstantNames(0x1000, Module)
5805+ v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5806+ Return v7
5807+ "# ] ] ) ;
5808+ }
5809+
57345810 #[ test]
57355811 fn eliminate_array_size ( ) {
57365812 eval ( "
@@ -5880,7 +5956,7 @@ mod opt_tests {
58805956 bb0(v0:BasicObject):
58815957 PatchPoint SingleRactorMode
58825958 PatchPoint StableConstantNames(0x1000, Foo::Bar::C)
5883- v7:BasicObject [VALUE(0x1008)] = Const Value(VALUE(0x1008))
5959+ v7:ClassExact [VALUE(0x1008)] = Const Value(VALUE(0x1008))
58845960 Return v7
58855961 "# ] ] ) ;
58865962 }
@@ -5897,7 +5973,7 @@ mod opt_tests {
58975973 bb0(v0:BasicObject):
58985974 PatchPoint SingleRactorMode
58995975 PatchPoint StableConstantNames(0x1000, C)
5900- v20:BasicObject [VALUE(0x1008)] = Const Value(VALUE(0x1008))
5976+ v20:ClassExact [VALUE(0x1008)] = Const Value(VALUE(0x1008))
59015977 v4:NilClassExact = Const Value(nil)
59025978 v11:BasicObject = SendWithoutBlock v20, :new
59035979 Return v11
@@ -5920,7 +5996,7 @@ mod opt_tests {
59205996 bb0(v0:BasicObject):
59215997 PatchPoint SingleRactorMode
59225998 PatchPoint StableConstantNames(0x1000, C)
5923- v22:BasicObject [VALUE(0x1008)] = Const Value(VALUE(0x1008))
5999+ v22:ClassExact [VALUE(0x1008)] = Const Value(VALUE(0x1008))
59246000 v4:NilClassExact = Const Value(nil)
59256001 v5:Fixnum[1] = Const Value(1)
59266002 v13:BasicObject = SendWithoutBlock v22, :new, v5
0 commit comments