DefObj in conflict with elements predefinded structures

I am using the DefObj o statement. Unexpectedly, this declaration is applied also to elements of predefined structures. The example below fails with an error.

DefObj o
Sub Main
  oSheet = ThisComponent.Sheets(0)
'...
  Dim Constraints(1) as new com.sun.star.sheet.SolverConstraint
  With Constraints(0)
    .Left = oSheet.getCellRangeByName("G15").CellAddress
    .Operator = com.sun.star.sheet.SolverConstraintOperator.LESS_EQUAL
    .Right = 1.5
  End With
'...
End Sub

The error is that the .Operator element is interpreted as an object. After removing the statement DefObj everything is OK.
Is this behavior consistent with the intention to use the DefObj statement? Can I disable this statement locally?

This is a bug - please report.

I have reported [https://bugs.documentfoundation.org/show_bug.cgi?id=147571]. Thank you.

I temporarily applied the following solution. I rearranged the order of the procedures so that DefObj statement follows the procedure that references the .Operator element
I had to add a Dim oSheet As Object declaration. I have more changes in the real code.